我只是找不到一种算法来将字符串拆分为多个分隔符的单词。我知道如何使用 istringtream
按空格拆分字符串,以及使用 getline
按单个定界符 拆分字符串。我怎样才能将它们全部连接起来。
例如:
输入:This -is-a!,string;
输出:
This
is
a
string
最佳答案
为什么不只是 #include <cstring>
并使用 std::strtok()
在你的 C++ 程序中?
关于c++ - C++ 中的 strtok() 模拟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16807188/