Simple Write c ++ for File ReadingCodeTo keep your memory, write it down:
# Include <fstream> # include <string> # incclude <iostream> using namespace STD; void main () {string s; ifstream fin; ofstream fout; Fin. open ("F: \ 1.txt"); fout. open ("F: \ 1.txt"); While (! Fin. EOF () {Getline (FIN, S); // a row is read into fout <S <'\ n';} fin. close (); fout. close (); System ("pause ");}
System ("pause ");
System isProgramTo call system commands (and shell commands ). System ("pause") is to call the "pause" command from the program;
The function of the "pause" system command is very simple, that is, to output a line similar to "press any key to exit" on the command line, wait for the user to press a key, and then return.
C ++ files are read in many ways, and there are many related function interfaces. In the future, we will continue to consult relevant materials for improvement.