delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/13/21:48:34

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP inconsistencies?
Date: 13 Mar 1997 13:01:49 GMT
Organization: Oxford University, England
Lines: 34
Message-ID: <5g8trt$7um@news.ox.ac.uk>
References: <5g7p5i$abl AT netra DOT montana DOT edu> <01bc2fa7$9893d3c0$8c081ecb AT sly>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019