TermSpar

Output Filestream

Apr 23rd, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main () {
  8.  
  9.     ofstream myFile("myTest.txt");
  10.  
  11.     if(myFile.is_open()){
  12.        
  13.         string uInput;
  14.         cout << "Enter data to write: ";
  15.         cin >> uInput;
  16.         myFile << uInput;
  17.  
  18.     }else{
  19.         cerr << "File Unable To Open!" << endl;
  20.     }
  21.    
  22.     system("pause");
  23.     return 0;
  24. }
Add Comment
Please, Sign In to add comment