C Programming :: Variable Number of Arguments
-
Point out the error in the program.
#include
#define MAX 128 int main() { char mybuf[] = "Fresher"; char yourbuf[] = "GATE"; char *const ptr = mybuf; *ptr = 'a'; ptr = yourbuf; return 0; } -
What will be the output of the program?
#include
-
What will be the output of the program?
#include
void fun1(char, int, int *, float *, char *); void fun2(char ch, ...); void (*p1)(char, int, int *, float *, char *); void (*p2)(char ch, ...); int main() { char ch='A'; int i=10; float f=3.14; char *p="Hello"; p1=fun1; p2=fun2; (*p1)(ch, i, &i, &f, p); (*p2)(ch, i, &i, &f, p); return 0; } void fun1(char ch, int i, int *pi, float *pf, char *p) { printf("%c %d %d %f %s \n", ch, i, *pi, *pf, p); } void fun2(char ch, ...) { int i, *pi; float *pf; char *p; va_list list; printf("%c ", ch); va_start(list, ch); i = va_arg(list, int); printf("%d ", i); pi = va_arg(list, int*); printf("%d ", *pi); pf = va_arg(list, float*); printf("%f ", *pf); p = va_arg(list, char *); printf("%s", p); } -
What will be the output of the program?
#include
-
What will be the output of the program?
#include
void display(int num, ...); int main() { display(4, 'A', 'B', 'C', 'D'); return 0; } void display(int num, ...) { char c, c1; int j; va_list ptr, ptr1; vastart(ptr, num); va_start(ptr1, num); for(j=1; jint); printf("%c", c); c1 = va_arg(ptr1, int); printf("%d\n", c1); } } -
What will be the output of the program?
#include