简单的ini文件解析
int GetKeyVal(const string strCfg, const string strKey, string& strVal){ int nRet = em_succ; if (strKey.length() <= 0) { return em_err_param; } FILE* fp = fopen(strCfg.c_str(), "rt"); if (NULL == fp) { return em_err_open_file; } char szReadLine[ROLE_DEF_MAX_LINE_LEN] = {0}; memset(szReadLine, 0, ROLE_DEF_MAX_LINE_LEN); nRet = em_err_no_result; while (EOF != (fscanf(fp, "%[^\n]", szReadLine))) { fgetc(fp);//read '\n' string strLine = szReadLine; memset(szReadLine, 0, sizeof(szReadLine)); vector<string> vtSec = SplitString(strLine, "="); if ((vtSec.size() <= 1) || (vtSec.size() > 2)) { continue; } else if (strKey == vtSec[0]) { strVal = vtSec[1]; nRet = em_succ; break; } } if (NULL != fp) { fclose(fp); fp = NULL; } return nRet;}?