zoukankan      html  css  js  c++  java
  • C语言基本数据类型大小

    C语言基本数据类型占用的字节数可以通过如下例子获取:

    #include<stdio.h>
    
    int  main(void)
    {
        printf("char size=%d 
    ",sizeof(char));
        printf("int size=%d 
    ",sizeof(int));
        printf("long size=%d 
    ",sizeof(long));
        printf("float size=%d 
    ",sizeof(float));
        printf("double size=%d 
    ",sizeof(double));
        printf("char* size=%d 
    ",sizeof(char*));
        printf("int* size=%d 
    ",sizeof(int*));
        printf("long* size=%d 
    ",sizeof(long*));
        printf("float* size=%d 
    ",sizeof(float*));
        printf("double* size=%d 
    ",sizeof(double*));
        printf("char[] size=%d 
    ",sizeof(char[2]));
        return 0;
    }

    执行结果:

    $ ./size.exe
    char size=1
    int size=4
    long size=8
    float size=4
    double size=8
    char* size=8
    int* size=8
    long* size=8
    float* size=8
    double* size=8
    char[] size=2

    以上,单位是字节,一个字节为8比特

    其中需要注意的是任何类型的指针变量占用8个字节

  • 相关阅读:
    C#中的String与string
    类和结构的异同点?
    HTTP 无状态啊无状态啊
    重载运算符
    Lambda与委托
    Js与正则表达式
    字符函数PATINDEX()与STUFF()
    C#中的托管与非托管
    原码,反码,补码
    日期函数与转型
  • 原文地址:https://www.cnblogs.com/jason207489550/p/6663478.html
Copyright © 2011-2022 走看看