Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!julius.cs.uiuc.edu!rpi!uupsi!cci632!dsg From: dsg@cci632.UUCP (David Greenberg) Newsgroups: comp.sys.amiga Subject: Re: Compairing C values Message-ID: <49780@cci632.UUCP> Date: 5 Feb 91 20:34:53 GMT References: Reply-To: dsg@ccird1.UUCP (David Greenberg) Organization: Computer Consoles Inc. an STC Company, Rochester, NY Lines: 49 > I have + as an input arguement via *argv[] and whenever I try to >compare its value it comes out as a 0. For instance... If I compile a >program like this: > >#include >#include > >void main(int argc, char *argv[]) > >{ > > And I type "test +" (I would name the file test) it would just print a >equals 0. Any help would be appereciated... >char a = argv[1]; >if (a = '+') printf("a equals +"); >if (a = '0') printf("a equals '0'"); >if (a = 0) printf("a equals 0"); >} I think you want to use a double '=' here ie : (a='+' sets a equal to plus) a=='+' tests for equality) if (a == '+') printf("a equals +\n"); if (a == '0') printf("a equals '0'\n"); if (a == 0) printf("a equals 0\n"); /* don't know what you are doing here?? */ (Also, use \n (newlines) to output the line. C uses buffered output and will not print until a newline (\n) is encountered (or an fflush(stdout) is done). OR you could use a switch statement: switch (a) { case '+': printf("a equals +\n"); break; case '0': printf("a equals '0'\n"); break; default: printf("Neither + or '0'\n"); } Hope this is what you need.. Dave