使用sizeof()运算符来获取数组大小

#include <stdio.h>

int main()
{
    int intarray[100];
    float floatarray[100];
    double doublearray[100];

    printf("/n/nSize of int = %d bytes", sizeof(int));
    printf("/nSize of short = %d bytes", sizeof(short));
    printf("/nSize of long = %d bytes", sizeof(long));
    printf("/nSize of long long = %d bytes", sizeof(long long));
    printf("/nSize of float = %d bytes", sizeof(float));
    printf("/nSize of double = %d bytes", sizeof(double));

    /* Display the sizes of the three arrays */

    printf("/nSize of intarray = %d bytes", sizeof(intarray));
    printf("/nSize of floatarray = %d bytes", sizeof(floatarray));
    printf("/nSize of doublearray = %d bytes/n", sizeof(doublearray));

    return 0;
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/266713.html

(0)
上一篇 2022年6月7日 23:12
下一篇 2022年6月7日 23:12

相关推荐

发表回复

登录后才能评论