Advertisement
Robert_JR

Double file input

Nov 1st, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. //Double file input
  2. #include <bits/stdc++.h>
  3. #define endl "\n"
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9.     FILE *f1, *f2;
  10.     int n1, n2;
  11.     //cout << "Hello Robert" << endl;
  12.     f1 = fopen("in1.txt", "r");
  13.     f2 = fopen("in2.txt", "r");
  14.  
  15.     while(fscanf(f1, "%d", &n1) != EOF)
  16.     {
  17.         //cout << "here" << endl;
  18.         fscanf(f2, "%d", &n2);
  19.         cout << n1 + n2 << endl;
  20.     }
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement