Is there a C++ iterator that can iterate over a file line by line?

后端 未结 7 1018
忘了有多久
忘了有多久 2020-12-01 07:18

I would like to get an istream_iterator-style iterator that returns each line of the file as a string rather than each word. Is this possible?

7条回答
  •  既然无缘
    2020-12-01 07:40

    You could write your own iterator. It's not that hard. An iterator is just a class on which (simply speaking) the increment and * operators are defined.

    Look at http://www.drdobbs.com/cpp/184401417 to get started writing your own iterators.

提交回复
热议问题