3q
see below, brother.
==============
#include <iostream>
#include <cstdarg> // for va_list, va_start, va_end, va_arg
using namespace std;
bool debug = false;
void DebugOutput(const char* formartString, ...)
{
va_list ap;
if(debug)
{
va_start(ap, formartString);
vfprintf(stderr, formartString, ap);
va_end(ap);
}
}
void SquareInts(int counter, ...)
{
int temp;
va_list ap;
va_start(ap, counter);
for(int i=0; i<counter; ++i)
{
temp = va_arg(ap, int);
cout<<temp*temp<<" ";
}
va_end(ap);
cout<<endl;
}
int main()
{
debug = true;
DebugOutput("This is the debug output\n");
DebugOutput("int %d\n", 13);
DebugOutput("My name is %s and I am %d years old\n", "John Doe", 20);
DebugOutput("lots of integers here %d %d %d %d %d\n", 5, 7, 6, -3, 90);
cout<<"---------------------------------------------------------"<<endl;
SquareInts(3, 40, 23, -20);
return 0;
}