CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Interview Success Kit - Get Success in Job Interviews Interview Success Kit - 30,000 Interview Que. & Ans.
Covers 30,000+ Interview Questions asked in actual MNC Interviews - all with model answers.

Sponsored Links

Interview Questions
Our Services

INTERVIEW QUESTIONS C FUNCTIONS IN C DETAILS
Question :
How can send unlimited no of arguments to a function, eg printf function can take any no of arguments


Category Functions in C Interview Questions
Rating (4.2) By 36 users
Added on 7/19/2011
Views 2280
Rate it!


Answers:

Source: CoolInterview.com

using va_list variables in stdarg.h headerfile
Source: CoolInterview.com



Source: CoolInterview.com

Sending the unlimited number of arguments to a function can be done by "Variable number of arguments" concept in C.

These function definitions will contain an ellipse(...) which indicates the variable number of argument. example

#include <stdio.h>
#include <stdarg.h>

void eprintf (const char *template, ...)
{
va_list ap;
extern char *program_invocation_short_name;

fprintf (stderr, "%s: ", program_invocation_short_name);
va_start (ap, template);
vfprintf (stderr, template, ap);
va_end (ap);
}

Here va_Start() initializes variable argument list pointer ap to the beginning of the variable argument list, before any calls to va_arg().

The va_arg() macro returns the next argument in the variable argument list pointed to by ap.


For a clear example refer :
http://www.linuxvalley.it/encyclopedia/ldp/manpage/man3/stdarg.3.php
Source: CoolInterview.com



Posted by: Syed Baseer Ahmed

Contact Syed Baseer Ahmed Contact Syed Baseer Ahmed

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification Enter the above shown code: *
    Inform me about updated answers to this question

    Related Questions
    View Answer
    We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind()

    View Answer
    How argc and argv works in the following main function?


    main(int argc,char *argv[])
    { int n,i=0;
    while(argv[1][i]!='
    View Answer
    How to write a program such that it will delete itself after exectution?


    View Answer
    output of the following program
    void main()
    {
    unsigned i;
    i=100*400;
    printf(

    View Answer
    When function say abc() calls another function say xyz(), what happens in stack?

    View Answer
    In c , main() is a function . and where is defined main() in c. bcz every function has three parts.
    1>. decleration
    2>. definition.
    3>. calling

    View Answer
    How to write a C program to find the power of 2 in a normal way and in single step?

    View Answer
    What is the difference between goto and longjmp() and setjmp()?
    View Answer
    How do you determine whether to use a stream function or a low-level function?
    View Answer
    Is it better to use a macro or a function?
    View Answer
    How do you use a pointer to a function?
    View Answer
    Why should I prototype a function?
    View Answer
    What is a static function?
    View Answer
    Is using exit() the same as using return?
    View Answer
    Differentiate between a linker and linkage?
    View Answer
    What is a function and built-in function?
    View Answer
    What is an argument ? differentiate between formal arguments and actual arguments?
    View Answer
    What is the purpose of main( ) function?
    View Answer
    What are the advantages of the functions?
    View Answer
    What is a method?
    View Answer

    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL Functions in C Interview Questions & Answers

    User Options
    India News Network

    Latest 20 Questions
    If the debit and credit aspects of a transaction are recorded in the cash book it is a: a) Contra Entry b) Simple Entry c) Double Entry d) Single Entry
    Small payments are recorded in a book called: a) Cash Book b) Small Payments Book c) Purchase Book d) Petty Cash Book
    Cash book is a form of: a) Trial balance b) Ledger c) Journal d) All of the above
    The balance of Petty Cash is: a) An Expense b) Revenue c) An Asset d) Liability
    Briefly define top-down and bottom-up design model ?
    What is the basis of Halstead?s complexity measure?
    Differentiate validation and verification ?
    What is structured design ?
    What is data dictionary?
    What is level-0 DFD ?
    Mentions some software analysis & design tools?
    What is software metric?
    What is software measure ?
    What is feasibility study ?
    What are software requirements?
    What is change control?
    What is Software configuration management?
    What is baseline?
    What are function points ?
    How can we derive the size of software product?



    Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

    Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

    MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
    MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

    GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

    IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
    IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

    SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
    SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




    Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions



    Cache = 0.021484 Seconds