linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Winters <chuckw@ieee.org>
To: linux-c-programming@vger.kernel.org
Subject: Re: processing arguments
Date: Fri, 23 Apr 2004 19:40:51 -0500	[thread overview]
Message-ID: <1082767251.3606.2.camel@whatever.local> (raw)
In-Reply-To: <Pine.LNX.4.58.0404231743080.1006@debian>

Ameer,
  Your if stmt:
    if(argv[1] == "hello")
  is only comparing the pointer values in memory.  You need
  to use strncmp(3) to do comparison on strings.

Chuck

On Fri, 2004-04-23 at 16:44, ameer armaly wrote:
     Hi all.
     Let's say that I have the following c++ code:
     #include <iostream>
     int main(int argc, char *argv[])
     {
     if(argv[1]=="hello")
     cout <<"Hello World!";
     return 0;
     }


     When I try that, and I type:
     ./a.out hello

     It doesn't give me any output.
     Can someone explain how to process args properly?
     Thanks,


     Ameer

     -
     To unsubscribe from this list: send the line "unsubscribe linux-c-
     programming" in
     the body of a message to majordomo@vger.kernel.org
     More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2004-04-24  0:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-23 21:44 processing arguments ameer armaly
2004-04-24  0:40 ` Chuck Winters [this message]
2004-04-24  0:58 ` A. Murat Eren
2004-04-24  5:06 ` vadiraj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1082767251.3606.2.camel@whatever.local \
    --to=chuckw@ieee.org \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).