Groups | Search | Server Info | Login | Register


Groups > comp.lang.c.moderated > #507

Re: How to declare a function parameter to be optional?

From Francis Glassborow <francis.glassborow@btinternet.com>
Newsgroups comp.lang.c.moderated
Subject Re: How to declare a function parameter to be optional?
Date 2011-02-09 12:22 -0600
Organization Usenet Fact Police
Message-ID <clcm-20110209-0001@plethora.net> (permalink)
References <clcm-20110207-0001@plethora.net>

Show all headers | View raw


On 08/02/2011 04:58, Pushkar Prasad wrote:
> Hello All
>
> Is there a way to ensure that one of the function argument is set as
> optional. So that it is not mandatory for the caller to pass that
> parameter and yet if necessary can be used?

Not in C.
>
> I do remember that it is possible, but I can't seem to find that
> information. Any guidance will be of great help.

I think you are remembering something from C++ where there are two ways 
of achieving this (default arguments and function overloading)

The best you can do in C is to use  '...' to allow an unspecified list 
of arguments (printf() is an example of a function that uses this)

-- 
ACCU Conference 2011 The one you cannot afford to miss
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.

Back to comp.lang.c.moderated | Previous | Next | Find similar


Thread

Re: How to declare a function parameter to be optional? Francis Glassborow <francis.glassborow@btinternet.com> - 2011-02-09 12:22 -0600

csiph-web