Erasing using backspace control character

后端 未结 4 573
一个人的身影
一个人的身影 2020-12-02 19:09

I am trying to use the backspace control character \'\\b\' to erase trailing commas at the end of line. Although it works in cases where there is no other outpu

4条回答
  •  悲&欢浪女
    2020-12-02 19:51

    Or, if you're fond of C+11 hacks:

    adjacent_difference(a.begin(), a.end(), ostream_iterator(std::cout),
      [](int x, int)->int { return std::cout << ",", x; });
    

提交回复
热议问题