How to print an entire istream to standard out and string

后端 未结 5 772
既然无缘
既然无缘 2021-01-03 22:39

How do you print an istream variable to standard out. [EDIT] I am trying to debug a scenario wherein I need to ouput an istream to a log file

5条回答
  •  误落风尘
    2021-01-03 23:37

    You ouput the istream's streambuf.

    For example, to output an ifstream to cout:

    std::ifstream f("whatever");
    std::cout << f.rdbuf();
    

提交回复
热议问题