Why is this program's output different between C and C++?

Viewed 1176

Possible Duplicate:
Size of character ('a') in C/C++

The following program

#include <stdio.h>

int main()
{
    printf("%d\n", sizeof('\0'));
    printf("%d\n", sizeof(0));
}

compiled with gcc outputs

4
4

and with g++

1
4

Why is this happening? I know this it's not a compiler thing but a difference between C and C++ but what's the reason?

4 Answers
Related