delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/28/19:33:52

Message-ID: <37780627.1A6A720@calderathin.com>
Date: Mon, 28 Jun 1999 17:32:55 -0600
From: Jared Stevens <stevja AT calderathin DOT com>
X-Mailer: Mozilla 4.6 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Command Line parameters
References: <19990628174003 DOT 22728 DOT 00000953 AT ng-ch1 DOT aol DOT com>
Reply-To: djgpp AT delorie DOT com

This is a multi-part message in MIME format.
--------------B8D4111C56F04286DBD78162
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit



FixAllPCs wrote:
> 
> Could someone show me an example of command line parameters, please.  I'm
> working on a project that would have input like:
> 
> program_name parameter1 parameter2 parameter3
> 
> That sort of thing.
> 
> Thanks,
> Tom Beauchamp
--------------B8D4111C56F04286DBD78162
Content-Type: text/plain; charset=us-ascii;
 name="ex1.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ex1.c"

#include <stdio.h>

void main(int argc, char *argv[])
{
  int i=0;
  for(i=0;i<=argc;i++)
    printf("This is arg 1, %s.", argv[i]);

  // argc is the amount of arguments
  // argv is an array of strings that contains the args.
  // element 0 is the path, 1-argc is the arguments.
} // end of main

--------------B8D4111C56F04286DBD78162--

- Raw text -


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