delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/05/02:20:30

Date: Thu, 5 Nov 1998 09:20:30 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: The zr0 <thezr0 AT aol DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: whats wrong w/ this code?
In-Reply-To: <19981104231513.27592.00001445@ng84.aol.com>
Message-ID: <Pine.SUN.3.91.981105092011.2883L-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On 5 Nov 1998, The zr0 wrote:

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

Bug no.1: `main' should return an int, like this:

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

>         for(count=2;count<argc;count++)

Bug no.2: arguments begin with argv[1], not argv[2] (argv[0] is the
program's pathname).

>         count++;
>         show_file(count,argv);

Bug no.3: you increment count *before* calling show_file, so you
actually begin with argv[3], and the last argument passed is
argv[argc], which is a NULL pointer.

- Raw text -


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