Question 4 of 145 points

Question 4 · 5 points

Trace fscanf followed by fgets

After this code executes, what exactly does word contain? Explain the file-position changes made by fscanf and fgets, and state what the printf call displays.

FILE *fp = fopen("input.txt", "r");
if (!fp) return 1;

int number;
char word[50];

fscanf(fp, "%d", &number);
fgets(word, sizeof(word), fp);

printf("Word is: %s", word);

fclose(fp);

input.txt contains:

100
Apple

Your response

Your answer

0 words