C Programming - Variable Number of Arguments - Discussion

Discussion Forum : Variable Number of Arguments - Find Output of Program (Q.No. 1)
1.
What will be the output of the program?
#include<stdio.h>
#include<stdarg.h>
void fun(char *msg, ...);

int main()
{
    fun("IndiaBIX", 1, 4, 7, 11, 0);
    return 0;
}
void fun(char *msg, ...)
{
    va_list ptr;
    int num;
    va_start(ptr, msg);
    num = va_arg(ptr, int);
    num = va_arg(ptr, int);
    printf("%d", num);
}
IndiaBIX 1 7 11 0
1
4
7
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
34 comments Page 3 of 4.

Saurabh said:   1 decade ago
I didn't get it ! Can anyone expalin in little more detail ?

ALEX said:   1 decade ago
Why we use ... (only 3 dots) for variable arguments?

Kowshik said:   9 years ago
How to work this?

Please anyone explain me clearly.

Anshu said:   1 decade ago
Yes I also thinks what shiv z saying, dats correct.

Akash said:   1 decade ago
What does it mean va_start(ptr, msg);?

Kiran said:   1 decade ago
@irshad::thanks for your explination.

Riya said:   1 decade ago
can anyone explain this please......

Anjali said:   1 decade ago
Sir please explane how it comes.

Akash Kharade said:   1 decade ago
Thanx friends.....now i got it.

Virat said:   1 decade ago
Please explain this question.


Post your comments here:

Your comments will be displayed after verification.