Read newline using stream C++

前端 未结 4 2113
伪装坚强ぢ
伪装坚强ぢ 2021-01-26 18:08

How do I also read a new line using C++ >> operator?

ifstream input(\"doc.txt\".c_str());
vector contents;
while (input >> word) {
    conten         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-26 18:26

    First off , you are already passing as const char * in the constructor of the stream. Secondly , the stream reader reads characters not space , this is how it knows when to cut to strings.

    Usually we read a binary file , there is a character known by the reader that tells when we skip a line the famous \n but its differents from platforms(Win , Unix).

提交回复
热议问题