Xref: utzoo comp.arch:3006 comp.lang.c:5827 Path: utzoo!mnetor!uunet!husc6!cmcl2!phri!roy From: roy@phri.UUCP (Roy Smith) Newsgroups: comp.arch,comp.lang.c Subject: Re: Null-terminated C strings Message-ID: <3087@phri.UUCP> Date: 24 Dec 87 03:05:00 GMT References: <174@quick.COM> <14116@think.UUCP> <2447@hall.cray.com> Reply-To: roy@phri.UUCP (Roy Smith) Followup-To: comp.lang.c Organization: Public Health Research Inst. (NY, NY) Lines: 27 In article <2447@hall.cray.com> blu@hall.UUCP (Brian Utterback) writes: > At least the compiler should issue a warning if it eats a null. I mean, > what is the use of being able to specify a character in a string (i.e. > \000) if the compiler won't really use it? Interesting question. Should a \000 in a string constant be flagged as a warning by the compiler? On both my 4.3 Vax and 3.2 Suns, the following program draws no complaint: main () { printf ("this\000probably won't print\n"); } Even lint has nothing to say (other than complaining about printf's return value being ignored on the Sun). Surely at least lint should pick up this one. There is nothing strictly illegal about imbedding a null in a string constant, but it is strange. One might want to do: printf ("this\000probably won't print\n"+5); and the compiler should let you do it, although I can't think of any valid reason offhand you would *want* to do such a thing. -- Roy Smith, {allegra,cmcl2,philabs}!phri!roy System Administrator, Public Health Research Institute 455 First Avenue, New York, NY 10016