Mail Archives: djgpp/1998/01/28/08:01:06
From: | spark AT es DOT co DOT nz (Zippy)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | why won't my .exe program run properly until I set env var?
|
Date: | Thu, 29 Jan 1998 02:01:08 +1200
|
Organization: | The Internet Group (Dunedin)
|
Lines: | 56
|
Message-ID: | <spark-2901980201090001@p113-thalia.es.co.nz>
|
NNTP-Posting-Host: | chaos.es.co.nz
|
Cache-Post-Path: | Chaos.es.co.nz!unknown AT p113-thalia DOT es DOT co DOT nz
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I am new to DJGPP, so this might be a dumb q, but here it goes...
I run DJGPP within a DOS window in Windows95. I've got a batch file which
sets the path and the environment var. So the procedure I take to use
DJGPP is
1. Start up a DOS window from windows95
2. Run the batch file (which has
set djgpp=c:\djgpp\djgpp.env
set path=c:\djgpp\bin;%path%)
3. Start programming
OK, I wrote a very short program that renames a file.
#include <stdio.h>
main(int argc, char *argv[])
{
char *d, *p, *n, *e;
int dummy = fnsplit(argv[1], d, p, n, e);
/* This splits a filename into drive, path, name and extension. */
dummy = rename("oldname.txt", strcat(n, ".txt"));
}
The idea was to pass the new filename to the .exe program and rename the
file "oldname.txt" into the new one.
I compiled the program by typing in
gcc nameit.c -o nameit.exe
Now I run the program by typing in
nameit newname
and the old file is rename to "newname.txt" The program works.
So far so good.
I quit the DOS window and start up another DOS window to run the program
again. However since I am not programming, I don't run the batch file.
I run the renaming program, and strangely, it doesn't work. I managed to
trace the problem down to the environment variable not being set, ie.
after starting a new DOS window, if I type in the line
set djgpp = c:\djgpp\djgpp.env
and then run the renaming program, it works.
Now, this is what I don't understand. Why do I need to set the variable
when I am running the stand-along .exe file?
Please someone enlighten me.
--
spark AT es DOT co DOT nz
- Raw text -