Difficulty: Easy
Correct Answer: Reposition the file pointer to beginning of file.
Explanation:
Introduction / Context:
The function rewind(stream)
is part of the C standard I/O library. This question tests understanding of file positioning and status flags for streams opened via fopen
or related functions.
Given Data / Assumptions:
FILE*
opened earlier.rewind
.
Concept / Approach:
rewind(stream)
moves the file position indicator to the beginning of the file and clears both the error and end-of-file indicators for that stream. It does not return a value. This contrasts with functions like fseek
/fseeko
which return status codes and can position relative to various origins.
Step-by-Step Solution:
ferror
.
Verification / Alternative check:
Behavior mirrors fseek(stream, 0, SEEK_SET)
followed by clearerr(stream)
, but rewind
is the concise, standardized helper for this common action.
Why Other Options Are Wrong:
Character reverse: There is no such notion in standard C I/O.
End of file: rewind
goes to the start, not the end.
Beginning of that line: Line concepts are not known to the stream positioning API.
Common Pitfalls:
rewind
also clears EOF and error indicators.
Final Answer:
Reposition the file pointer to beginning of file.
Discussion & Comments