给定的C代码
#include <stdio.h>
int x = 14;
size_t check()
{
struct x {};
return sizeof(x); // which x
}
int main()
{
printf("%zu",check());
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在我的32位实现上给出4作为C的输出,而在C++中给出代码
#include <iostream>
int x = 14;
size_t check()
{
struct x {};
return sizeof(x); // which x
}
int main()
{
std::cout<< check();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出1.为何如此差异?