我有以下代碼:std::string str = "abc def,ghi";std::stringstream ss(str);string token;while (ss >> token){ printf("%s\n", token.c_str());}輸出為:abcdef,ghi因此,stringstream::>>運算符可以按空格分隔字符串,但不能用逗號分隔。無論如何,有沒有修改上面的代碼,以便我可以得到以下結果?輸入:“ abc,def,ghi”輸出:abcdefghi
- 2 回答
- 0 關注
- 1898 瀏覽
添加回答
舉報
0/150
提交
取消