本文尽可能多的测试了在win32平台下用sizeof()求各种类型变量字节数的结果,而且会不断更新。很有参考价值哦!
sizeof(char)=1sizeof(short)=2sizeof(int)=4sizeof(long)=4sizeof(float)=4sizeof(double)=8sizeof(long double)=8sizeof(unsigned char)=1sizeof(unsigned short)=2sizeof(unsigned int)=4sizeof(unsigned long)=4sizeof(unsigned float)=4sizeof(unsigned double)=4sizeof(unsigned long double)=8char a[] = {'a','b','c','d','e'};//sizeof(a)=5char b[] = "abcde";//sizeof(b)=6char c[][3] = {{'a','b','c'},{'d','e','f'},{'g','h','i'},{'j','k','l'}};//sizeof(c)=12//sizeof(c[0])=3//sizeof(c[0][0])=1char d[][5] = {"abcc","deff","ghii","jkll"};//sizeof(d)=20//sizeof(d[0])=5//sizeof(d[0][0])=1char *p = 0;//sizeof(p)=4char *q = (char *)malloc(5);//sizeof(q)=4char *r = "abcde";//sizeof(r)=4char (*f)(void) = NULL;//sizeof(f)=4char *s1[3] = {"aa","bb","cc"};//sizeof(s1)=12//sizeof(s1[0])=4//sizeof(*s1[0])=1char *s2[3][3] = {{"aa","bb","cc"},{"aa","bb","cc"},{"aa","bb","cc"}};//sizeof(s2)=36//sizeof(s2[0])=12//sizeof(*s2[0])=4char h[3][3] = {{1,2,3},{4,5,6},{7,8,9}};char (*ph)[3] = h;//sizeof(ph)=4//sizeof(*ph)=3//sizeof(ph[0])=3//sizeof(*ph[0])=1