File Handling & Standard Template Library (STL) Flashcards
7 cards from real CPP practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 File Handling & Standard Template Library (STL) flashcards as text
What is the effect of opening a file with std::ios::app mode?
Answer: All writes go to the end of the file regardless of seekp()
In append mode, every write operation automatically moves the put pointer to end-of-file before writing.
Which STL container adaptor uses a std::deque as its default underlying container?
Answer: Both std::stack and std::queue
Both std::stack and std::queue default to std::deque as their underlying container.
What does std::lower_bound() return when no element satisfies the condition?
Answer: The end iterator of the range
std::lower_bound returns the end iterator if all elements are less than the value.
Which method checks whether a std::fstream has reached end-of-file?
Answer: std::fstream::eof()
eof() returns true when the eofbit is set, indicating end-of-file has been reached.
What is the time complexity of std::list::splice()?
Answer: O(1)
std::list::splice() moves elements between lists in O(1) by relinking pointers.
Which STL iterator category supports both increment and decrement but NOT random access?
Answer: Bidirectional iterator
Bidirectional iterators support ++ and -- but not arbitrary +n or -n arithmetic.
What does std::transform() do?
Answer: Applies a function to a range and stores results in another range
std::transform applies a unary or binary operation to each element and writes results to an output range.