如何在C++中用'/'分割字符串

问题描述

我有 unordered_set 的字符串。

而且,在输入时我得到一个文件。 比如这种字符串。

“AA/BB/CC”

“YY/XX”

“BB/DD/LL”

我想在我的集合中看到这个:

AA

AA/BB

AA/BB/CC

BB

BB/DD

BB/DD/LL

YY

YY/XX

std::string instances_file { "/home/areg/Desktop/instance_file.txt" };
std::string str { "\n\t\r" };
char delimiter {'/'};
std::ifstream ifs (instances_file);

while(std::getline(ifs,str,delimiter))
     unoset.insert(str);

能否请您提供一个 STL 算法来执行此操作,或者帮我编写代码

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)