Did you use a file named ".c" or some C++ file extension (".cpp", ".cxx",
etc)?For me, in C++ it returns 1, in C returns 4. Carlos Guía On Tue, Jan 10, 2012 at 1:31 AM, Shahadat Sarker <[email protected]>wrote: > Hi > my gcc (Ubuntu 10.0.4) give the below output: > a > ch= 1 a=1 char=1 > > ------------------ > (program exited with code: 0) > Press return to continue > > > > > > On Mon, Jan 2, 2012 at 12:51 PM, 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. > -- 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.
