i have logging function takes in variable number of arguments , uses _vsnprintf format them. problem when debug ocr automation string returns sent log, if file said this:
this bitmap says %n
then sent logging function this:
void log(lpcstr msg, ...) { char log[max_allowed]; int length = sizeof(log) / sizeof(log[0]); va_list argptr; va_start( argptr, pzmsg ); // our msg accidentally has % if ( strchr(msg, '%') ) { // debug assertion - no parameters passed _vsnprintf( log, length, msg, argptr ); } log[length-1] = (char)0; va_end( arg_ptr ); }
is there way, along check '%' can check if there no arguments? thank you.
the traditional way make sure can't expanded printf is
log("%s", yourstring);
of course, add variant of log
takes 1 argument, or count number of variable arguments , not format string if there aren't any.
Comments
Post a Comment