神奇的sizeof

内容会持续更新,有错误的地方欢迎指正,谢谢!

char* c = "HelloWorld";
char  ca[11] = "HelloWorld";
cout << sizeof(c) << endl;//4
cout << sizeof(ca) << endl;//11
testArray是一个包含8个元素的int类型数组,sizeof(testArray)/sizeof(testArray[0])的值?

sizeof(testArray) 是数组大小 8*4  =32;
sizeof(testArray[0]) 是 testArray[0]的大小 4;
所以 sizeof(testArray)/sizeof(testArray[0]) = 8

猜你喜欢

转载自blog.csdn.net/BillCYJ/article/details/79823538