From mboxrd@z Thu Jan 1 00:00:00 1970 From: Branko Cibej To: Peter Seebach Cc: egcs@cygnus.com Subject: Make Money Fast (was: Re: linux libio status) Date: Thu, 16 Oct 1997 02:35:00 -0000 Message-id: <3445B57B.EAAF8231@hermes.si> References: <199710151909.OAA21070@monolith.solon.com> X-SW-Source: 1997-10/msg00639.html Peter Seebach wrote: > However, correctness aside, it is good to use NULL for null pointers, > for the same reason it is good to use "hello, world" rather than > { 'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd' } > to initialize arrays of characters. > > (One point extra credit for spotting the difference, two points > extra credit for spotting the case where the two are not different.) Here you are, then: /* sizeof(diff1) == sizeof(diff2) + sizeof('\0') */ char diff1[] = "hello, world"; char diff2[] = { 'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd' }; /* sizeof(same1) == sizeof(same2) == sizeof(diff2) */ char same1[12] = "hello, world"; char same2[12] = { 'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd' }; (Who said you couldn't get free credit over the Net? :-) -- Branko Cibej HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia phone: (++386 61) 186 53 49 fax: (++386 61) 186 52 70