Consider the following code snippet:
#include
#include
void display(int num, ...) {
char c;
int j;
va_list ptr;
While using va_arg the char
is promoted to int
. There are other types(the list given by @R..) which are promoted.
so in order to read it as a char
you have to do typecast.
like: c = (char) va_arg(ap, int);
for the complete example please see:
http://en.cppreference.com/w/cpp/language/variadic_arguments