ANDERS FLODERUS wrote in
Is it possible to transfer a variable length argument
list? What I want to do is just
void myPrintf( char *pFormat, ... ) {
char buf[256];
sprintf( buf, pFormat, ... );
.
.
.
return;
}
which obviously will not compile. If possible, I would
like to do it without using the va_... macros while stepping
throu the format specifier. I suppose it would be possible
althou I do not know what type the arguments are (could
be found in the format specifier?).
#include <cstdio>
#include <cstdarg>
void myPrintf( char const *pFormat, ... )
{
using namespace std;
char buf[256];
va_list va;
va_start( va, pFormat );
vsprintf( buf, pFormat, va );
/* _vsnprintf is non standard but your compiler may provide it.
If so its *safer* than the above.
*/
//_vsnprintf( buf, sizeof buf, pFormat, va );
va_end( va );
printf( "buf = [%s]\n", buf );
}
int main()
{
myPrintf("test %d", 1 );
}
HTH.
Rob.