iOS、swift技术交流!

sizeof

2015-11-27  本文已影响29人  光明程辉

sizeof是C语言的一种单目操作符,如C语言的其他操作符++、--等。
它并不是函数。
sizeof操作符以字节形式给出了其操作数的存储大小。
操作数可以是一个表达式或括在括号内的类型名。
操作数的存储大小由操作数的类型决定。

include <stdio.h>

int main()
{
//int size = sizeof(10);  // 是可以的
//int size = sizeof 10.9; // 是可以的

int a = 10;

//int size = sizeof(a); // 是可以的
//int size = sizeof a;  // 是可以的

int size = sizeof(char);
// int size = sizeof char; // 错误的

printf("size=%d\n", size);

return 0;
}
上一篇 下一篇

猜你喜欢

热点阅读