Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   hw does printf(),scanf() nd all work?? (http://www.velocityreviews.com/forums/t595724-hw-does-printf-scanf-nd-all-work.html)

jt 03-03-2008 02:11 PM

hw does printf(),scanf() nd all work??
 
everytime we pass different number of variables.
even though there is no polymorphism concept in C.
hw do they accomplish.

santosh 03-03-2008 02:25 PM

Re: hw does printf(),scanf() nd all work??
 
jt wrote:

> everytime we pass different number of variables.
> even though there is no polymorphism concept in C.
> hw do they accomplish.


The format string specifies everything that they need to know (and
expect) of the following arguments. In C, functions with variadic
arguments can accept differing number and type of arguments though they
must accept at least one fixed parameter. This is a somewhat advanced
topic in C. You don't need to worry about their actual mechanics until
much later.


Kenneth Brody 03-03-2008 02:53 PM

Re: hw does printf(),scanf() nd all work??
 
jt wrote:
>
> everytime we pass different number of variables.
> even though there is no polymorphism concept in C.
> hw do they accomplish.


"Variadic functions", aka "varargs". The functions are defined as
taking an unspecified list of parameters of unspecified types.

For example:

int printf(const char * restrict format, ...);

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap@gmail.com>



All times are GMT. The time now is 10:12 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.