Are both these codes the same
char ch = \'a\';
printf(\"%d\", ch);
Will it print a garbage value?
I am confused about this
In C, character constant expressions such as '\n' or 'a' have type int (thus sizeof '\n' == sizeof (int)), whereas in C++ they have type char.
The statement printf("%d", '\0'); should simply print 0; the type of the expression '\0' is int, and its value is 0.
The statement printf("%d", ch); should print the integer encoding for the value in ch (for ASCII, 'a' == 97).