Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

printf function of C


  • Please log in to reply

#1
anu_bhatnagar24

anu_bhatnagar24

    New Member

  • Member
  • Pip
  • 2 posts
Hi friends...
can anyone help me with this query?


C does not have polymorphism, then how does printf have variable
number of arguments?



Thanx! :-)
  • 0

Advertisements


#2
darth_ash

darth_ash

    Member 1K

  • Member
  • PipPipPipPip
  • 1,382 posts
I think u should get ur basics right.
Polymorphism has got nothing to with no. of arguments in a function. Polymorphism is the ability to use the same function-name with differrent retur-types and different arguments (no. or type).

printf uses the "..." operator, to get variable no. or arguments at runtime.
(U can confirm by looking at the declartion of printf in ur help-file)
  • 0

#3
anu_bhatnagar24

anu_bhatnagar24

    New Member

  • Topic Starter
  • Member
  • Pip
  • 2 posts
Hmm.... :tazz:
And yes i hav 2 work a lot on my c/c++. Just begun learning c/c++ in my current semester.
Thanx a lot.
  • 0

#4
timinator

timinator

    Member

  • Member
  • PipPip
  • 18 posts
Speaking of getting the basics right,
The ellipses notation ("...") is not an "operator". And, with a couple exceptions, function overloading doesn't include return types (note that I didn't use the term polymorphism for that statement, because it often refers to something else).

C/C++ can support a variable number of arguments because of how arguments are pushed onto the stack (when using the normal calling convention); other languages use the stack differently and can't support a variable number of function arguments.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP