O
Obnoxious User
Hi,
Can someone tell me what is wrong with the below program?
-------------------------------------------
int main()
{
f1( 25 > 50,"testing stdarg. ", "it is working", "if it is
working." );
return 0;
}
void f1(bool condition, const char * msg,...)
{
va_list ap;
va_start(ap, msg);
while (msg != 0 )
{
cout<< msg<<endl;
msg = va_arg(ap, const char *);
}
va_end(ap);
}
--------------------------------------------
the ouput is
------------------------------------------
testing stdarg.
it is working
if it is working.
UH??AWAVAUATSH??8H?E?
Cleaned up and compilable version of your code.
#include <cstdarg>
#include <iostream>
void f1(bool condition, const char * msg,...)
{
va_list ap;
va_start(ap, msg);
while (msg != 0 )
{
std::cout<< msg<<std::endl;
msg = va_arg(ap, const char *);
}
va_end(ap);
}
int main()
{
f1( 25 > 50,"testing stdarg. ", "it is working", "if it is working.",0 );
return 0;
}