In C++ stream I/O (<iostream> and <fstream>), which of the following is NOT a valid seek direction enumerator (std::ios_base::seekdir) used by seekg() or seekp()?
In C++ stream I/O (<iostream> and <fstream>), which of the following is NOT a valid seek direction enumerator (std::ios_base::seekdir) used by seekg() or seekp()?
Multiple Choice Options
- A
ios::beg
- B
ios::end
- C
ios::cur
- D✓ Correct Option
ios::set
Detailed Technical Solution & Explanation
In standard C++ file streams (std::basic_istream and std::basic_ostream), the seekg() (seek get) and seekp() (seek put) member functions position file pointers relative to a reference point specified by std::ios_base::seekdir. The language standard defines exactly three seek directions:
1. std::ios::beg: Offset relative to the beginning of the stream.
2. std::ios::cur: Offset relative to the current stream position.
3. std::ios::end: Offset relative to the end of the stream.
There is no direction named ios::set. (The C POSIX function lseek uses SEEK_SET, but in C++ streams it is ios::beg).
Option Analysis:
ios::set does not exist in standard C++ streams.