C++ cout auto separator

后端 未结 7 1745
半阙折子戏
半阙折子戏 2020-12-13 17:36

I am wondering if there is way that std::cout automatically will insert some predefined value between printed sequences.

For example:

st         


        
7条回答
  •  抹茶落季
    2020-12-13 18:08

    Not quite the same thing, but:

    #include 
    #include 
    #include 
    
    int main() {
        std::array data = { 1, 2, 3 };
        std::ostream_iterator out(std::cout, " ");
        std::copy(data.begin(), data.end(), out);
        std::cout << '\n';
        return 0;
    }
    

提交回复
热议问题