delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/07/19:44:57

Sender: nate AT cartsys DOT com
Message-ID: <369553F5.FF6EDBA8@cartsys.com>
Date: Thu, 07 Jan 1999 16:40:21 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.0.36 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: command line parameters
References: <7736ma$f4q$1 AT fe2 DOT cs DOT interbusiness DOT it>
Reply-To: djgpp AT delorie DOT com

Bonifati wrote:
> 
> I'm a novice and need help:
> programming in C++, how can I take command line string parameters?

Use the parameters to `main'.  Experiment with this program, it should
give you an idea.

(This is C but C++ works the same.)

#include <stdio.h>

int main(int argc, char *argv[])
{
  int i;
  for (i = 0; i < argc; i++)
    printf("argv[%d] = \"%s\"\n", i, argv[i]);
  return 0;
}

For more info, see your C++ book.  Get one.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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