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

_snprintf 会不会有执行失败的时候?该如何解决

2012-03-09 
_snprintf 会不会有执行失败的时候?返回值正负都有含义。那么0代表执行失败?[解决办法]If len count, the

_snprintf 会不会有执行失败的时候?
返回值正负都有含义。那么0代表执行失败?

[解决办法]
If len = count, then len characters are stored in buffer, no null-terminator is appended, and len is returned.
msdn的解释
[解决办法]
If buffer is a null pointer and count is nonzero, or format is a null pointer, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, these functions return -1 and set errno to EINVAL.


[解决办法]

if (-1 == _snprintf(...))
{
if (errno != EINVAL)
//返回错误;
}
[解决办法]
有执行失败的时候,GetLastError

热点排行