Path: utzoo!attcan!uunet!mcvax!unido!rwthinf!ruso!wolfgang From: wolfgang@ruso.UUCP (Wolfgang Deifel) Newsgroups: comp.lang.c Subject: Re: "do ... while ((NULL + 1) - 1);" -- valid C? Message-ID: <826@ruso.UUCP> Date: 10 Aug 89 08:55:56 GMT References: <1043@levels.sait.edu.au> Organization: Dr. Ruff Software GmbH, Aachen, W.Germany Lines: 15 ccdn@levels.sait.edu.au (DAVID NEWALL) writes: > do > ... > while ((s = strchr(s, ',') + 1) - 1); >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. Why should NULL + 1 not be valid ??? NULL is a pointer with the value 0 and you can add the integer 1 to it ( but you cannot access *s in the case strchr is NULL of course ). Wolfgang.