I have a program that takes in ip addresses and breaks them up into 4 octets which are strings. Then I convert them into integers. I am having a problem with running the loop to take in each address. It only runs once so it takes in only 1 ip address.
Here is my Code:
If I put a cout<<oct1 : it does nothing.Code:ifstream in("input.txt"); ofstream out("output.txt"); string line; string octet1; string octet2; string octet3; string octet4; int i = 0; while ( ! in.eof()) { while(getline(in,line)) { //out<< "[ " << line << " ]"; while(line[i] != '.') { octet1 = octet1 + line[i]; i++; } cout<<octet1<<" "; i++; while(line[i] != '.') { octet2 = octet2 + line[i]; i++; } cout<<octet2<<" "; i++; while(line[i] != '.') { octet3 = octet3 + line[i]; i++; } cout<<octet3<<" "; i++; while(i != line.length()) { octet4 = octet4 + line[i]; i++; } cout<<octet4<<endl; } int oct1; int oct2; int oct3; int oct4; oct1= atoi(octet1.c_str()); oct2= atoi(octet2.c_str()); oct3= atoi(octet3.c_str()); oct4= atoi(octet4.c_str());