creating an ostream

前端 未结 4 605
走了就别回头了
走了就别回头了 2021-01-05 08:09

I am trying to create a c++ ostream for educational reasons. My test will be creating an ostream that acts like a ofstream would except instead of writing to a file it would

4条回答
  •  灰色年华
    2021-01-05 09:04

    Use std::stringstream

    #include 
    #include 
    int main()
    {
        std::stringstream   s;
        s << "Plop" << 5;
    
        std::cout << s.str();
    }
    

提交回复
热议问题