Hello. There was a problem when working with files, I provide the code:
#define _CRT_SECURE_NO_WARNINGS #include "stdafx.h" #include "stdio.h" #include "stdlib.h" int main() { int a, b; FILE *fp; FILE *fp2; if ((fp = fopen("input", "r")) != NULL) { fscanf(fp, "%d %d\n", &a, &b); printf("yes.\n"); } else { printf("no"); } fclose(fp); fp2 = fopen("output", "w"); fprintf(fp2, "%d %d\n", a, b); fclose(fp2); exit(1); return 0; } I will describe the situation. There are 2 files: input and output. The first one contains several lines in each of which there are two numbers, separated by a space, say as in the example below: 5 6 7 15 9 568 23 75
The task to output to the output file is the same as in input, but when compiling the code above, only the first line is output to output, i.e. 5 6 and the rest not. What to add or remove in the code to solve the problem? Thank.