Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How does C++ read txt file line by line and import the read data into another file through operation?
How does C++ read txt file line by line and import the read data into another file through operation?
1. First, we create a new folder on the computer, named txt2array. Then, open our devc++ and create a new console c++ project, also known as txt2array.

2. Store the project files, source code files and data files we demonstrated in the txt2array folder.

3. Write some demonstration data into the data file.

4. Read the document. Enter the following code: Run it as if we read it successfully. Ifile.good () returns the status of the current stream.

5. Store data in an array and perform type conversion.

6. After reading the file data, we convert it into numbers and save it in the array.