Date: Thu, 13 Mar 1997 13:16:05 -0500 (EST) From: "art s. kagel IFMX x2697" To: Andy Bober Cc: djgpp AT delorie DOT com Subject: Re: DJGPP inconsistencies? In-Reply-To: <33280F93.B9B@uxa.ecn.bgu.edu> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII There is nothing wrong with the original string. \" does indeed imbed a quote character within a quoted string. Art S. Kagel, kagel AT ts1 DOT bloomberg DOT com On Thu, 13 Mar 1997, Andy Bober wrote: > [snip] > > > Also, I sometimes get random compiler "parse" errors when I include > > > the following code in a program: > > > > > > char *str; > > > if ( (str = getenv("DEM_PATH")) == NULL) { > > > printf("\"DEM_PATH\" environment variable not set\n"); > > > exit(1); > > > } > > > > > > Yet again...WHY? > > > [snip] > > It's your nested double quotes. How many strings are in the printf() > line? > > Parse of printf() string: > > "\" --- this starts and ends one null > terminated string > DEM_PATH\ --- this is a syntax error > " environment variable not set\n" --- this starts and ends a second > null terminated string > > > Try the line like this: > char *str; > if ( (str = getenv("DEM_PATH")) == NULL) { > printf("'DEM_PATH' environment variable not set\n"); > exit(1); > } > > > If you need to use the the backslashes as characters in the string, I > believe they must be doubled. ( ie. "\\DEM_PATH\\ environment variable > not set\n" ) > > Andy >