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 char
gets promoted to int
in expressions. That pretty much explains every question, if you think about it.
Source: The C Programming Language by Brian W.Kernighan and Dennis M.Ritchie
A must read if you want to learn C.
Also see this stack overflow page, where people much more experienced then me can explain it much better then I ever can.