hey I am having confusion in the output of a simple program.
here is the code:-
int main(void)
{
printf("%d %d",sizeof('A'),sizeof("A"));
return 0;
}
output on my compiler(gcc):- 4 2.
I thought sizeof("A") is considered as string ending with '\0' so there are two characters i.e,2 bytes a resulting 2 as an output.
and if instead of sizeof("A") if there is sizeof("AS") output is 3.
But why for sizeof('A') output is 4,i.e, its considering the sizeof(int) instead.
Please explain the reason for both.
and also for the code
int main(void)
{
int i=0;
printf("%d",++i + ++i + ++i);
}
why output is 7 ?