您的位置:首页 > Web前端

Buffer too small

2013-07-30 13:29 274 查看
在项目中用到了CString,后来发现在Format的时候会报Buffer too small的错误,在网上查资料发现时这样的

CString output ;
int size = m_NicInfo.size();
output.Format(_T("共%d块网卡\r\n"),size);
//VE_NicINFO_IT  it = this->m_NicInfo.begin();
//for(; it != m_NicInfo.end(); ++it){
//	CString tmp;
//	tmp.Format(_T("网卡GUID:%s\r\n"),it->NicGUID);
//	output += tmp;
//	tmp.Format(_T("网卡描述:%s\r\n"),it->NicDesc);
//	output += tmp;
//	tmp.Format(_T("网卡名称:%s\r\n"),it->NicName);
//	output += tmp;
//	tmp.Format(_T("网卡注册表中INDEX:%s\r\n"),it->NicClassIndex);
//	output += tmp;
//}

for(int pos = 0; pos < size ; pos++)
{
CString tmp;
tmp.Format(_T("网卡GUID:%s\r\n"),m_NicInfo.at(pos).NicGUID);
output += tmp;
tmp.Format(_T("网卡描述:%s\r\n"),m_NicInfo.at(pos).NicDesc);
output += tmp;
tmp.Format(_T("网卡名称:%s\r\n"),m_NicInfo.at(pos).NicName);
output += tmp;
tmp.Format(_T("网卡注册表中INDEX:%s\r\n"),m_NicInfo.at(pos).NicClassIndex);
output += tmp;
}
writeLog(output);


  在使用Format函数的时候,不用以自己作为函数参数,否则就会出现Buffer too small的情况
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: