I guess the compiler treats 'a' as an integral constant and ends up using
int to represent it.

Carlos Guía


On Mon, Jan 2, 2012 at 2:51 AM, Shoubhik <[email protected]> wrote:

>    #include<stdio.h>
>
>    int main()
>    {
>
>            char ch;
>            fflush(stdin);
>            ch=getchar();
>            printf("ch= %d a=%d char=%d",
> sizeof(ch),sizeof('a'),sizeof(char));
>
>
>    }
>
> I type in 'a' (without quotes) as input , and the output I got in my
> ***gcc version 4.5.1*** is :
>
> ch= 1 a=4 char=1
>
> My question is :
>
> If sizeof(c) is 1 , then how can sizeof('a') be 4 ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to