Advertisement
Waliul

Files in C

Sep 27th, 2019
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int v1, v2, sum;
  5.     FILE *fp, *fpw;
  6.     fp = fopen("F:\\input.txt", "r");
  7.     fpw = fopen("F:\\output.txt", "w");
  8.     while(fscanf(fp, "%d %d", &v1, &v2) != EOF)
  9.     {
  10.         sum = v1 + v2;
  11.         fprintf(fpw, "Sum of %d and %d is = %d\n", v1, v2, sum);
  12.     }
  13.     fclose(fp);
  14.     fclose(fpw);
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement