int FormatString(char* buffer,int buflen,char* format,...)
{
va_list args;
va_start(args, format);
int len = _vsnprintf(buffer, buflen, format, args);
va_end(args);
return len;
}
调用方式
char buffer[512]; FormatString(buffer,sizeof(buffer),"{\"key\":\"%d\"}",1); printf(buffer);