读书人

vsprintf_s函数的quot;%squot;参数不需要付出长

发布时间: 2013-11-03 15:39:14 作者: rapoo

vsprintf_s函数的"%s"参数不需要给出长度么??


void MsgBox(const char* szFormat, ...)
{
if (szFormat == NULL)return;

char szInfo[1024] = { 0 };

// 获取信息
{
va_list argPtr;
va_start(argPtr, szFormat);
vsprintf_s(szInfo, sizeof(szInfo), szFormat, argPtr);// 将格式化符转换为最终的字符串
va_end(argPtr);
}

MessageBoxA(0, szInfo, "", MB_OK);
}


MsgBox()函数的调用,其"%s"参数不需要给出长度么?

1: MsgBox("%s %d", "123", sizeof("123"), 10);
2: MsgBox("%s %d", "123", 10);

是像第2个那样调用么?
[解决办法]
2: MsgBox("%s %d", "123", 10);
是的,和printf一样

读书人网 >C++

热点推荐