Interview Questions

C/C++ Questions only (Variable-Length Argument Lists)

C++ programming on UNIX, C++ Networking,C++ Algorithm Questions and Answers


(Continued from previous question...)

C/C++ Questions only (Variable-Length Argument Lists)

1. I heard that you have to #include <stdio.h> before calling

printf. Why?

2. How can %f be used for both float and double arguments in printf?

3. Why don't function prototypes guard against mismatches in

printf's arguments?

4. How can I write a function that takes a variable number of

arguments?

5. How can I write a function that takes a format string and a

variable number of arguments, like printf, and passes them to printf

to do most of the work?

6. How can I write a function analogous to scanf, that calls scanf

to do most of the work?

7. I have a pre-ANSI compiler, without <stdarg.h>. What can I do?

8. How can I discover how many arguments a function was actually

called with?

9. My compiler isn't letting me declare a function that accepts only

variable arguments.

10. Why isn't "va_arg(argp, float)" working?

11. I can't get va_arg to pull in an argument of type

pointer-to-function.

12. How can I write a function which takes a variable number of

arguments and passes them to some other function ?

13. How can I call a function with an argument list built up at run

time?

(Continued on next question...)

Other Interview Questions