Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.lang.c Subject: Re: "do ... while ((NULL + 1) - 1);" -- valid C? Message-ID: <961@virtech.UUCP> Date: 8 Aug 89 01:44:06 GMT References: <1043@levels.sait.edu.au> Organization: Virtual Technologies Inc Lines: 17 In article <1043@levels.sait.edu.au>, ccdn@levels.sait.edu.au (DAVID NEWALL) writes: > > I've been told that this is not valid C because, in the case that there > are no more fields (commas), strchr() returns NULL; and NULL + 1 is not > valid. NULL, in this case, is just a pointer that has the value 0. NULL + 1 is a valid operations, however *(NULL+1) is not. I wouldn't code the loop as you have displayed because one has to spend time thinking about what the will is trying to do. A "better" method would be something like: do ...; s = strchr(s,','); while ( s++ != NULL );