operations on files in c++ -
For example, we have created a file in C ++ how to write content in this file and then output to the screen?
Write:
#include & lt; Iostream & gt; # Include & lt; Fstream & gt; using namespace std; Int main () {ofstream myfile; Myfile.open ("example.txt"); MyFile & lt; & Lt; "It is typing in the file. \ N"; Myfile.close (); Return 0; }
Reading:
#include & lt; Iostream & gt; # Include & lt; Fstream & gt; #include & lt; String & gt; using namespace std; Int main () {string line; Ifstream myfile ("example.txt"); While (gateline (mime, line)) {cout & lt; & Lt; Line & lt; & Lt; Endl; } Myfile.close (); Return 0; }
You really should use Google.
Comments
Post a Comment