Null revisited (briefly)
D. Jason Penney
penneyj at servio.UUCP
Wed Feb 15 09:40:44 AEST 1989
I strongly disagree with Bill Davidsen's suggestion for null-terminating
C strings. I submit the following example as safer, cleaner, and more
legible:
char aString[20];
aString[0] = '\0';
'x' is a literal of type char. Thus, '\0' is the char with value 0,
which is really what was intended here.
When you assign an int or a pointer to a character, the reader ends
up wondering if the type mismatch is unintentional.
--
D. Jason Penney Ph: (503) 629-8383
Servio Logic Corporation uucp: ...ogccse!servio!penneyj
15220 NW Greenbrier Parkway #100
Beaverton, OR 97006
More information about the Comp.lang.c
mailing list