c & c++中sizeof返回值不同?

问题: A character array is defined globally and a structure with same name is defined within a function. 一个字符数组被定义为全局变量,一个相同名字的结构体被定义在一个函数内部。 Why sizeof operator returns different values for c & c++ ? 为什么sizeof操作符对于C和C++返回了不同的值呢? char S[13]; void fun() { struct S { int v; }; int v1 = sizeof(S); } // returns 4 in C++ and 13 in C 答案: Because in C++, the struct you defined is named S, while in C, 因为在C++中,你定义的结构体的名称是S,而在C中, [Read More]