0
다음 코드가 있습니다.boost :: algorithm :: split을 사용하여 문자열을 분할하십시오.
using namespace std;
using namespace boost;
int main()
{
SystemConnect hndl;
int ip1[15],ip2[15];
string line;
while (cout<<"LP>" && getline(cin,line)) {
if (line=="exit")
break;
if (line=="Connect 10.172.21.121 10.109.12.122"){
string str;
str="ConInit 10.172.21.121 10.109.12.122";
vector<string> results;
split(results,str,is_any_of(" "));
for(vector<string>::const_iterator p=results.begin();p!=results.end();p++){
cout<<*p<<endl;
}
}
}
}
이것은 내가 얻는 결과입니다.
Connect
10.172.21.121
10.109.12.122
나는 IP2에서 IP1 & 10.109.12.122에서 10.172.21.121을 저장해야합니다. 내가 어떻게
감사
왜 ip1과 ip2가 int []로 정의되어 있습니까? 어떤 형태로 IP 주소를 저장하길 기대합니까? –
왜 IP 주소를 저장하기 위해 15- 요소 int 배열이 필요하다고 생각하십니까? –