주어진 C 코드 C에있는 반면, 제 32 비트 구현에 C의 출력으로서호환성 C 및 C 사이 ++ 코드
#include <stdio.h>
int x = 14;
size_t check()
{
struct x {};
return sizeof(x); // which x
}
int main()
{
printf("%zu",check());
return 0;
}
준다 4 ++ 코드
#include <iostream>
int x = 14;
size_t check()
{
struct x {};
return sizeof(x); // which x
}
int main()
{
std::cout<< check();
return 0;
}
출력 1. 왜 이러한 차이?
가능한 중복 항목 : http://stackoverflow.com/questions/3451266/understanding-sizeofchar-in-32-bit-c-compilers http://stackoverflow.com/questions/119123/why-isnt-sizeof-for -a-struct-like-of-the-sum-of-each-member – phooji
@phooji : 아니, 그건 중복이 아닙니다. –
@Saurabh : 당신이 옳을 수도 있습니다. 질문들이 정확히 같은 땅을 덮지는 않지만, 그 답변들은 관련이 있다고 생각합니다. (Prasoon의 답변과 당신의 대답에 대한 나의 코멘트를보십시오). – phooji