#include <iostream>
#include <fstream>
int main() {
std::string line;
std::ifstream IPFile;
// ipconfig: IPv6 Address. . . . . . . . . . . : 2021:a83:85c3:0000:0000:1e2e:0180:7555
char IPv6Line[] = "IPv6 Address. . . . . . . . . . . :";
char line1 = 1;
system("ipconfig > ip.txt");
IPFile.open("ip.txt");
if (IPFile.is_open()) {
while(!IPFile.eof()) {
getline(IPFile, line);
if (line.find(IPv6Line, 0) != std::string::npos && line1 == 1) {
line1 = 2;
continue;
}
if (line.find(IPv6Line, 0) != std::string::npos) {
line.erase(0, 39);
std::cout << line << "\n";
IPFile.close();
}
}
}
return 0;
}
/*
run:
2021:a83:85c3:0000:0000:1e2e:0180:7555
*/