ID Number: Q77481
6.00 6.00a 6.00ax
MS-DOS
docerr
Summary:
There is an error in the ENVIRON.C program included in the online help
for Microsoft C versions 6.0, 6.0a, and 6.0ax and QuickC versions 2.5
and 2.51. The program is designed to demonstrate such environment
variable functions as putenv(), but it does not work correctly
as written. The line in the program that reads
strcat( pathbuf, ";\\QC;" );
should be replaced with the following three lines:
strcpy( pathbuf, "PATH=" );
strcat( pathbuf, pathvar );
strcat( pathbuf, ";\\QC25\\BIN;" );
Also, further down in the file, the line that reads
if( putenv( pathvar ) == -1 )
should be replaced with the following:
strcpy( pathbuf, "PATH=" );
strcat( pathbuf, pathvar );
if( putenv( pathbuf ) == -1 )
These changes give the pathbuf string the format that the putenv()
function requires to work properly.
More Information:
ENVIRON.C fails in its original form because the pathbuf string does
not start with "PATH=". The putenv() function requires a string of the
form "<environment variable>=<value>".
Note that the program does run as expected when compiled with C
version 5.1 or QuickC version 2.0, but only as the result of a known
bug in the putenv() function that was included with these versions. In
that particular implementation of the putenv() function, the entire
string was used as the environment variable, even if no equal sign was
found. The current version of putenv() expects an equal sign in the
environment string, and generates an error if it does not find one.
Additional reference words: 6.00 6.00a 6.00ax 2.50 2.51