delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/01/20:50:32

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Newbie question
Date: Tue, 01 Jul 1997 13:51:25 -0400
Organization: Cornell University
Lines: 36
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <33B9439D.69C3@cornell.edu>
References: <01bc861c$7c3537c0$b5fa41ce AT drkwatr>
NNTP-Posting-Host: 128
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019