题记-查找ini相同值 c++


   有A.txt 文件保存ini的键,从B.ini提取具有相同值的键。

   函数思想:1.需要按行提取A.txt文件里的字符串作键去读取B.ini里的信息

                     2.读取到值(设为V),后需要读取其他键下相对应的值。那么就需要循环做步骤1.同时需要将当前的键排除,直到A.txt的文件结尾

   函数实现:


void CheckTheSame(std::string filePath = "", std::wstring gtURL = L"", std::wstring gtwin7Url = L"")
{
	FILE *fRead;
	fRead = fopen(filePath.c_str(), "r"); 
	if (fRead)
	{
		int buffLen = 4096;
		char line[4096 + 1];
		char *pLine = line;
		std::wstring SameURl = gtURL;
		while (!feof(fRead))
		{
			int i = 0;
			while (!feof(fRead) && i < buffLen) //getline
			{
				char temp = fgetc(fRead);
				if (temp)
				{
					*(pLine + i) = temp;
					i++;
					if (temp == 10) //\n  换行标识符号
						break;
				}
			}
			*(pLine + i) = 0;
			wchar_t *wURL = StringAct::c2w(pLine);
			wchar_t *wtemp = wcschr(wURL, ' ');
			if (wtemp)
				*wtemp = 0;
			else
			{
				wtemp = wcschr(wURL, '\n');
				if (wtemp)
					*wtemp = 0;
			}
			wprintf(L"Down--%s\n", wURL);
			std::wstring URL = L"http://";
			URL += wURL;
			URL += L"/";
			StringAct::freeWChar(wURL);
			//校验
			wchar_t * url = L"SameSection";
			std::wstring downsInfo = FLYLIB::AppInfo::GetCurrentThisPath();
			downsInfo += L"downInfo.ini"; 
			wchar_t downUrl[1024];
			if (GetPrivateProfileString(URL.c_str(), url, L"", downUrl, 512, downsInfo.c_str()))
			{
				if (!gtURL.empty())
				{ 
					if ((URL != gtURL) && (gtwin7Url == downUrl))
					{
						SameURl += L"|";
						SameURl += URL;
					}
				}
				else
				{
					CheckDown(filePath, URL, downUrl);
				}
			}
		}
		fclose(fRead);
		if (!SameURl.empty())
		{
			wprintf("%s", SameURl.c_str())
			FILE *fWrite;
			std::string urlPath = FLYLIB::AppInfo::GetCurrentThisPathA();
			urlPath += "downUrlCheck.txt";
			fWrite = fopen(urlPath.c_str(), "a");
			if (fWrite)
			{
				SameURl += L"\n"; 
				char* temp = StringAct::w2c(SameURl.c_str());
				fwrite(temp, 1, strlen(temp), fWrite);
				StringAct::freeChar(temp);
		 		fclose(fWrite);
			}
		}
	} 
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值