首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

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

2013-11-03 
vsprintf_s函数的%s参数不需要给出长度么??void MsgBox(const char* szFormat, ...){if (szFormat NU

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一样

热点排行