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

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -