โ† All CPP Flashcard Decks

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
  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.