Mail Archives: djgpp/1997/07/01/20:50:32
DrkWatr wrote:
> 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.
the above code contains many elementary C programming errors. you should
see them if you compile with -Wall. of course, it makes no sense to post
the warnings lest they give some information to the people who might be
able to help you.
i do not see why you need to use arg_temp at all in the first place.
however, given that that's what you chose to do, here is a couple of
points:
> frame_skip = atoi (arg_temp[2]);
did you include <stdlib.h> (that's what you need for atoi) if you did,
gcc should give the following error message:
warning: passing arg 1 of `atoi' makes pointer from integer without a
cast.
> Also to debug it i would use a printf statement like
> the below.
> printf ("%s",arg_temp[1]);
arg_temp[1] is _not_ a pointer to a char array.
-- Sinan.
- Raw text -