sizeof() confusion

Rahul Dhesi dhesi%cirrusl at oliveb.ATC.olivetti.com
Fri Nov 9 04:28:50 AEST 1990


While we're on the subject of sizeof surprises, here is one that did
genuinely throw me off:

     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.
--
Rahul Dhesi <dhesi%cirrusl at oliveb.ATC.olivetti.com>
UUCP:  oliveb!cirrusl!dhesi



More information about the Comp.lang.c mailing list