concatenate stringstream in c++

后端 未结 6 467
没有蜡笔的小新
没有蜡笔的小新 2021-01-17 16:20

How can I concatenate two stringstreams?

#include 
#include 
#include 
#include 
#include <         


        
6条回答
  •  攒了一身酷
    2021-01-17 17:00

    More generically across iostreams:

    std::istream is1, is2; // eg. (i)stringstream
    std::ostream os;       // eg. (o)stringstream
    
    os << is1.rdbuf();
    os << is2.rdbuf();
    os << std::flush;
    

    This works for filestreams, std::cin etc. as well as for stringstream

提交回复
热议问题