Advertisement
skozombie

Simple file reader

Apr 21st, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. // Put the following line in a file called data.txt without comment markers:
  2. // MyName 42
  3. //
  4.  
  5. #include <iostream>
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11.         ifstream input;
  12.         input.open("data.txt");
  13.  
  14.         char name[100];
  15.         int grade;
  16.  
  17.         input >> name >> grade;
  18.         cout << "Name:  " << name << endl;
  19.         cout << "Grade: " << grade << endl;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement