From: "Martin Ambuhl" Newsgroups: comp.os.msdos.djgpp Subject: Re: C command line options Date: Wed, 27 May 1998 12:44:32 -0400 Organization: Nocturnal Aviation Lines: 43 Message-ID: <6khjcs$dg@news-central.tiac.net> References: NNTP-Posting-Host: p21.tc3.newyo.ny.tiac.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Clint Allen wrote in message ... :Anyone who can help on this? :I am trying to use command line options in my program. Here's what I've got :so far: : if (argv[1] == "/nts") ============= This is a question about C, not about djgpp. Get the FAQ for comp.lang.c from ftp://rtfm.mit.edu/pub/usenet-by-group. It has answers to this and many other questions, e.g. 8.2: I'm checking a string to see if it matches a particular value. Why isn't this code working? char *string; ... if(string == "value") { /* string matches "value" */ ... } A: Strings in C are represented as arrays of characters, and C never manipulates (assigns, compares, etc.) arrays as a whole. The == operator in the code fragment above compares two pointers -- the value of the pointer variable string and a pointer to the string literal "value" -- to see if they are equal, that is, if they point to the same place. They probably don't, so the comparison never succeeds. To compare two strings, you generally use the library function strcmp(): if(strcmp(string, "value") == 0) { /* string matches "value" */ ... } ==============