In the Windows operating system, files are divided into streaming files and record files. The latter can be read and written randomly, while the former can only be read sequentially. .txt is a streaming file and must be read sequentially, that is, the last line must be read before the 1000 in the last line can be read.
The c++ code is as follows: //Use the most basic stream operation to complete first:
//The file is assumed to be 1.txt
ifstream?in("1.txt");//Want to #include
string? s;
while(getline(in,s));
//At this point, you can operate in a variety of ways
//Method 1. String stream operations, directly saved to integer variables
string?temp,int?num;
istringstream?sin(s);
for(int ?i(1);sin>>temp&i<=4;++i);
sin>>num;//The value stored in num is 1000
//Method 2 .c++ function call, substr(), a member of the string class, check the usage yourself, it is also available in Baidu Encyclopedia
basic_string?
//Other methods: You can also use vector arrays, etc. Try it yourself.