Felanpro

<fstream> fun!!!!

Jun 27th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ofstream file1("c++test.txt");
  10.     string text;
  11.  
  12.     cout << "Send some text into the file. :)" << endl;
  13.  
  14.     cin >> text;
  15.  
  16.     file1 << text << endl; //We inserted "Hello" into the file.
  17.  
  18.     ifstream file1_read("c++test.txt");
  19.     file1_read >> text;
  20.     cout << text << endl;
  21.  
  22. }
Add Comment
Please, Sign In to add comment