你的分享就是我们的动力 ---﹥

VC str.Format 错误 Buffer too small

时间:2013-05-23 16:47来源:www.chengxuyuans.com 点击:
	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);

str.Format 错误 Buffer too small

The call will fail if the string object itself is offered as a parameter to Format. For example, the following code will cause unpredictable results:

 

CAtlString str = _T("Some Data");
str.Format(_T("%s%d"), str, 123);   
// Attention: str is also used in the parameter list.   

 

转载注明地址:http://www.chengxuyuans.com/Visual Studio/61819.html

推荐文章