資源簡介
C++讀取INI文件中指定Section下的所有key和keyvalue存放到map中
代碼片段和文件信息
string?U2A(const?wstring&?str)//Unicode字符轉Ascii字符??
{??
????string?strDes;??
????if?(?str.empty()?)??
????????goto?__end;??
????int?nLen=::WideCharToMultiByte(CP_ACP?0?str.c_str()?str.size()?NULL?0?NULL?NULL);??
????if?(?0==nLen?)??
????????goto?__end;??
????char*?pBuffer=new?char[nLen+1];??
????memset(pBuffer?0?nLen+1);??
????::WideCharToMultiByte(CP_ACP?0?str.c_str()?str.size()?pBuffer?nLen?NULL?NULL);??
????pBuffer[nLen]=‘\0‘;??
????strDes.append(pBuffer);??
????delete[]?pBuffer;??
__end:??
????return?strDes;??
}
void?testaaa(std::map?&mapCString?strFileNameCString?strSectionName)
{
std::string?str2;
CString?strKey?=?_T(““);
CString?strKeyName?=?_T(““);
CString?strKeyValue?=?_T(““);
TCHAR?szKey[1024]?=?{0};
TCHAR?szBuffer[4096]?=?{0};
//將指定Section下的所有key和value讀取到szBuffer中
int?nSizeCount?=?GetPrivateProfileSection(strSectionNameszBuffer4096strFileName);
for(int?n?=?0i=0;n {
if(szBuffer[
- 上一篇:物資管理系統 C語言
- 下一篇:機器人手臂
評論
共有 條評論