TermSpar

Input Filestream

Apr 23rd, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main () {
  8.  
  9.     ifstream myFile;
  10.     myFile.open("myTest.txt");
  11.  
  12.     int fileData;
  13.     myFile >> fileData;
  14.     int uAdd;
  15.  
  16.     cout << "Data From File: " << fileData << endl;
  17.     cout << "Add to value: ";
  18.  
  19.     if(myFile.fail()){
  20.         cerr << "File could not open!" << endl;
  21.     }
  22.    
  23.     system("pause");
  24.     return 0;
  25. }
Add Comment
Please, Sign In to add comment