Newsgroups: comp.lang.c Path: utzoo!telly!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Subject: Re: sizeof() confusion Organization: D'Arcy Cain Consulting, West Hill, Ontario Date: Sat, 10 Nov 90 12:32:04 GMT Message-ID: <1990Nov10.123204.8968@druid.uucp> References: <9156@latcs1.oz.au> <27432@mimsy.umd.edu> <2665@cirrusl.UUCP> In article <2665@cirrusl.UUCP> Rahul Dhesi writes: > [...] > main() { > char c; > c = 'c'; /* char variable holds char value */ > > printf("sizeof c = %d\n", sizeof c); > printf("sizeof 'c' = %d\n", sizeof 'c'); > printf("sizeof (char) = %d\n", sizeof (char)); > } > >Non-C wizards should try to guess what the program will print before >they run the program. OK, I'll byte. What's the suprise? I get 1, 4 and 1 on my 386 system which is exactly what I expected. Were you suprised that "'c'" was 4? You shouldn't be. That expression evaluates to an int, not a char. -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | I support gun control. West Hill, Ontario, Canada | Let's start with the government! + 416 281 6094 |