代码如下:
#include<stdio.h> int main() { printf("int:%d bytes ",sizeof(int)); printf("char:%d bytes ",sizeof(char)); printf("short:%d bytes ",sizeof(short)); printf("long:%d bytes ",sizeof(long)); printf("unsigned int:%d bytes ",sizeof(unsigned int)); printf("float:%d bytes ",sizeof(float)); printf("double:%d bytes ",sizeof(double)); }
结果:
int:4 bytes char:1 bytes short:2 bytes long:4 bytes unsigned int:4 bytes float:4 bytes double:8 bytes