#include <stdio.h> int main() {
#include <stdio.h>
int main() {
FILE *file = fopen("input.txt", "r");
int value;
fscanf(file, "%d", &value);
fseek(file, 0, SEEK_SET);
fscanf(file, "%d", &value);
fclose(file);
printf("%d\n", value);
return 0;
}
What will be the output of the code if input.txt contains 42?
Show answerHide answer
Correct answer: (B) 42
Explanation
The first fscanf reads 42. fseek(file, 0, SEEK_SET) moves back to the start, so the second fscanf reads 42 again, and 42 is printed.