www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/09/14:01:36

Newsgroups: comp.os.msdos.djgpp
From: fredex AT fcshome DOT stoneham DOT ma DOT us (Fred Smith)
Subject: Re: Problem compiling program with command-line arguments
Organization: None!
Message-ID: <Ez0K03.F8x@fcshome.stoneham.ma.us>
References: <Pine DOT SOL DOT 3 DOT 91 DOT 980909100830 DOT 11862A-100000 AT mercury>
Date: Wed, 9 Sep 1998 11:02:27 GMT
Lines: 24
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Goh Yong Kwang (s6606555 AT mercury DOT np DOT ac DOT sg) wrote:

This is probably off-topic for this newsgroup, but what the heck....


: ===================================================
: #include <stdio.h>

: // This program prints out all arguments passed to it from the command. 

: main(char *argv[], char argc){

Bingo! You've got the parameters backwrds, the first one is the argument
count (argc) and the second one the argument vector. Also note that
argc is an int, not a char. It should read:

main(int argc, char *argv[]){


--
---- Fred Smith -- fredex AT fcshome DOT stoneham DOT ma DOT us -----------------------------
                         For the wages of sin is death, 
            but the gift of God is eternal life in Christ Jesus our Lord
------------------------------ Romans 6:23 (niv) ------------------------------

- Raw text -


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