64,654
社区成员
发帖
与我相关
我的任务
分享
while (found_Pos != std::string::npos)
{
found_Pos = sub_ips.find(";", begin_Pos, 1);
std::string ip = sub_ips.substr(begin_Pos, found_Pos - begin_Pos);
if(ip.compare("127.0.0.1") == 0)
continue;
std::cout << ip << std::endl;
begin_Pos = found_Pos + 1;
found_Pos = sub_ips.find(";", begin_Pos, 1);
}
}
if(ip.compare("127.0.0.1") == 0)
{
begin_Pos = found_Pos + 1;
continue;
}
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string line;
std::ifstream in(L"a.txt");
while (std::getline(in, line) && !in.eof())
{
//std::cout << line << std::endl;
size_t pos = line.find("=");
if (pos == std::string::npos)
continue;
std::string sub_ips = line.substr(pos + 1, line.length() - pos - 1);
size_t begin_Pos = 0;
size_t found_Pos = 0;
size_t length = sub_ips.length();
while (found_Pos != std::string::npos)
{
found_Pos = sub_ips.find(";", begin_Pos, 1);
std::string ip = sub_ips.substr(begin_Pos, found_Pos - begin_Pos);
if(ip.compare("127.0.0.1") == 0)
continue;
std::cout << ip << std::endl;
begin_Pos = found_Pos + 1;
found_Pos = sub_ips.find(";", begin_Pos, 1);
}
}
cout<<"end";
std::cin.get();
return 0;
}