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

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -