delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/09/02/17:44:20

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: Thu, 2 Sep 2004 17:44:13 -0400
Message-Id: <200409022144.i82LiDLe005751@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <41378A42.5040801@acm.org> (message from Cesar Rabak on Thu, 02
Sep 2004 18:01:54 -0300)
Subject: Re: scanf: strange behavior?
References: <20040902144152 DOT GH6858 AT webhome DOT cz> <2pp00iFnf7nsU1 AT uni-berlin DOT de> <41374c9c$0$173$cc7c7865 AT news DOT luth DOT se> <20040902184005 DOT GA23943 AT webhome DOT cz> <41378A42 DOT 5040801 AT acm DOT org>
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> But: the use of the code above would be to collect arguments passed to 
> the command line _except_ yours have no variable to collect!
> 
> Since you have put in the body of your main, is no longer a prototype!

You apparently don't understand C++ enough.

The prototype given indicates that the function expects to be passed
two arguments, but does not need to reference them.  It is a
consequence of the ability to have *some* of the arguments unnamed as
placeholders (so that you don't get a warning about not using a named
parameter).  Consider:

	     int foo (char *a, int, int b) { }

The second parameter indicates that something *is* passed, and foo
*knows* about it, but doesn't use it.

Compare:

	int main() { }

This means that main doesn't expect any parameters.

	int main(int, char **) { }

This means that main expects parameters, but won't use them.

- Raw text -


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