How to print an entire istream to standard out and string

后端 未结 5 731
既然无缘
既然无缘 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:23

    std::ifsream overloading and std::ostringstream

    c++11 or upper


    Pay attention to && in std::ifstream that allow you to direct using

    #include 
    #include 
    #include 
    
    std::ostream& operator<<(std::ostream& os, std::basic_ostringstream&& iss){
        return os<

    output:

    Test ostringstream overloading
    Test fstream overloading
    
    
    Process returned 0 (0x0)   execution time : 0.012 s
    Press ENTER to continue.
    

提交回复
热议问题