Date: Sun, 2 Nov 1997 20:32:03 -0800 (PST) Message-Id: <199711030432.UAA13680@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: "Klywarre (THE AVATAR)" , djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: Newbie help Precedence: bulk At 10:35 11/1/1997 -0800, Klywarre (THE AVATAR) wrote: >Hello all, I'am trying to work with a test program in C, so far it's >working *somewhat*. First the code, then what is **not** working. > >#include >#include >#include > >// The following two lines are only temp's. >int fileflag = 1; >char filename[] = "DUMMY.MAP"; > >void main(int argc, char *argv[]) >{ > if(argc == 2) > if(strcmp(argv[1], "\\c")) [snipped] >>main \(any character will do -- tested) > when any character is used after the '\' character, the >message to enter a file name appears ---- not what it's supposed to >do!!! only when the option is '\c'. Yes. Your problem is that `strcmp()' returns 0 if the strings are the same, and nonzero if they differ. One would expect it to return a standard 1/0 true/false flag, but it doesn't. So that line wants to say: if(strcmp(argv[1], "\\c") == 0) I find it helps to think of strcmp as subtraction: It subtracts the second arg from the first, and returns the difference. Greater than 0 if arg1 was bigger, less if arg1 was less, and 0 if they are equal. Nate Eldredge eldredge AT ap DOT net