|
Thanks:fangjiehong,firegun,nimasile1
I understand all the programs you wrote, but the program I wrote (the one that only defines the fstream stream) compiles and runs without error, but it just can’t output s2 (a.txt was not created at all), so write it with you I have done a comparison of the programs or I don’t know why the a.txt text is not created? Can you analyze it for me? Thank you~~~~~
The program ofnimasile1uses an open() when writing text, and close() after writing. When reading variables, another open and then close(). Although the purpose is achieved, if you want to read and write repeatedly in a loop , I don’t feel very good.
The program offiregunis very good, but he didn't use ifstream, it used filebuf, ostream and istream.
The program ofliebersieis almost the same as mine, but after I run it, I still don’t get the s2 result (the output is empty and the text is not created). It should not be related to the compiler, right? |
|