Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!rex!uflorida!gatech!usenet.ins.cwru.edu!agate!eos!data.nas.nasa.gov!xenon.arc.nasa.gov!dueker From: dueker@xenon.arc.nasa.gov (Chris Dueker) Newsgroups: comp.sys.amiga Subject: Re: Compairing C values Message-ID: <1991Feb5.173012.20398@nas.nasa.gov> Date: 5 Feb 91 17:24:12 GMT References: Sender: news@nas.nasa.gov Reply-To: dueker@xenon.arc.nasa.gov Organization: NASA-Ames Research Center Lines: 34 News-Software: VAX/VMS VNEWS 1.3-4 In article , rat@hotcity.UUCP (P W) writes... > > 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"); >} Umm, if it's not a typo above, you should use "==" instead of "=" in the if stmts above. The "=" assigns the character to variable a, then if the result is true, the printf stmt is executed. Chris P.S. I'd have expected output from the first two printf's, since those results are non-zero (meaning true?). ------------------------------------------------------------------------ "Ah, Benson, you are so mercifully free of the ravages of intellegence!" "Oh, thank you, Master!" - from the movie, TIME BANDITS ------------------------------------------------------------------------ dueker@xenon.arc.nasa.gov | Chris Dueker (The Code Slinger) duke@well.sf.ca.us | Mtn. View, CA (Sillycon Valley!)