Make Money Fast (was: Re: linux libio status)
Branko Cibej
branko.cibej@hermes.si
Thu Oct 16 02:35:00 GMT 1997
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 <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
phone: (++386 61) 186 53 49 fax: (++386 61) 186 52 70
More information about the Gcc
mailing list