delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/27/12:45:36

From: "Martin Ambuhl" <mambuhl AT tiac DOT net>
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: <CyQa1.113$mR4 DOT 91692 AT news DOT internetmci DOT com>
NNTP-Posting-Host: p21.tc3.newyo.ny.tiac.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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" */
   ...
  }
==============





- Raw text -


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