Mail Archives: djgpp/1997/03/13/21:48:34
Sly (sly AT antispam DOT aussie DOT net) wrote:
: Paul Peavyhouse <pv AT cs DOT montana DOT edu> wrote in article
: <5g7p5i$abl AT netra DOT montana DOT edu>...
: > char *str;
: > if ( (str = getenv("DEM_PATH")) == NULL) {
: > printf("\"DEM_PATH\" environment variable not set\n");
: > exit(1);
: > }
: >
: That printf statement...is it a valid string in there? Shouldn't it be...
It's perfectly valid how it is; he's using the backslashes to escape the
inverted commas. It will actually print on the screen:
"DEM_PATH" environment variable not set
It's a slightly unclear technique; some people write %c tokens in the
string and put the ASCII code (34) in the parameters after the string,
e.g.
printf("%cDEM_PATH%c environment variable not set\n",34,34);
The difference is really irrelevant.
As for the error in this piece of code, until we see a complete source
file we can only speculate; my money is on some statements appearing
before this fragment, making the `char *s' definition invalid in standard
C programs.
--
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford
- Raw text -