Null revisited (briefly)

Farrell Woods ftw at masscomp.UUCP
Fri Mar 3 02:54:17 AEST 1989


In article <1783 at dlvax2.datlog.co.uk> scm at datlog.co.uk ( Steve Mawer ) writes:

>A single character written within
>single quotes is a *character constant*.  This isn't an int.

Wrong!

>'\0' is a special case to permit the representation of non-graphical
>characters (also newline, tab, backslash, return, etc.) and is not
>the same as 0, which is an integer constant.

Absolutely WRONG!  I strongly suggest you try this on your favorite
compiler:

main(ac, av)
    int ac;
    char **av;
    {

    printf("repeat after me: sizeof ('x') ==  %d\n", sizeof ('x'));
    printf("                 sizeof ('\\0') == %d\n", sizeof ('\0'));
    printf("                 sizeof (int) ==  %d\n", sizeof (int));
    printf("if these are not all the same, your compiler is broken!\n");
    exit(0);
    }

Study the results carfully...
-- 
Farrell T. Woods				Voice: (508) 692-6200 x2471
MASSCOMP Operating Systems Group		Internet: ftw at masscomp.com
1 Technology Way				uucp: {backbones}!masscomp!ftw
Westford, MA 01886				OS/2: Half an operating system



More information about the Comp.lang.c mailing list