sizeof运算符将变量名称或数据类型作为参数,并返回将数据存储在内存中所需的字节数。
#include <stdio.h>
int main()
{
int x;
float f;
double d;
char c;
typedef struct employee {
int id;
char *name;
float salary;
} e;
printf("/nSize of integer: %d bytes/n", sizeof(x));
printf("Size of float: %d bytes/n", sizeof(f));
printf("Size of double %d bytes/n", sizeof(d));
printf("Size of char %d byte/n", sizeof(c));
printf("Size of employee structure: %d bytes/n", sizeof(e));
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266711.html