Printing lists with commas C++

后端 未结 28 2135
时光取名叫无心
时光取名叫无心 2020-11-22 03:33

I know how to do this in other languages, but not C++, which I am forced to use here.

I have a Set of Strings that I\'m printing to out in a list, and they need a co

28条回答
  •  没有蜡笔的小新
    2020-11-22 04:00

    Could be like so..

    bool bFirst = true;
    for (auto curr = keywords.begin();  curr != keywords.end(); ++curr) {
       std::cout << (bFirst ? "" : ", ") << *curr;
       bFirst = false;
    }
    

提交回复
热议问题