Mail Archives: djgpp/1997/07/01/09:35:27
From: | "DrkWatr" <pawn AT dialnet DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Newbie question
|
Date: | 1 Jul 1997 12:40:15 GMT
|
Organization: | DialNet USENET News Service.
|
Lines: | 22
|
Message-ID: | <01bc861c$7c3537c0$b5fa41ce@drkwatr>
|
NNTP-Posting-Host: | rt1-ttyq1d5.dialnet.net
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I am having problems using command line arguments in my programs. I am used
to string handling in Turbo c++, so there is some differences in that
aspect. But tell me what you see that is wrong with the code below. It is
supposed to set the frame_skip variable according to the option -f2 if
present.
c:\game\source\freedom -f2
int main(int argc, char *argv[ ]);
/* some miscellaneous code here */
char arg_temp[10];
strcpy (arg_temp, argv[1]);
if ((arg_temp[0] == '-') && (arg_temp[1] == 'f'))
frame_skip = atoi (arg_temp[2]);
The above code works in Turbo c, but chokes in DJGPP, with numerous
warnings and errors. Also to debug it i would use a printf statement like
the below.
printf ("%s",arg_temp[1]);
but even though i declared it to be a string with only ten elements, it
would display a very long a wierd looking string instead of just a single
letter. And yes i did type in the parameter on the command line when i ran
it. any help would be greatly appreciated. Thanks in advance.
- Raw text -