C语言中sizeof()求字节数的应用举例

来源:本站
导读:目前正在解读《C语言中sizeof()求字节数的应用举例》的相关信息,《C语言中sizeof()求字节数的应用举例》是由用户自行发布的知识型内容!下面请观看由(电工技术网 - www.9ddd.net)用户发布《C语言中sizeof()求字节数的应用举例》的详细说明。

本文尽可能多的测试了在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

提醒:《C语言中sizeof()求字节数的应用举例》最后刷新时间 2024-03-14 01:05:32,本站为公益型个人网站,仅供个人学习和记录信息,不进行任何商业性质的盈利。如果内容、图片资源失效或内容涉及侵权,请反馈至,我们会及时处理。本站只保证内容的可读性,无法保证真实性,《C语言中sizeof()求字节数的应用举例》该内容的真实性请自行鉴别。