0

I have unordered_set of strings.

And, on input i get a file. For example, this kind of strings.

"AA/BB/CC"

"YY/XX"

"BB/DD/LL"

I want to see in my set this:

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);

Can you please provide a STL algorithm for doing this, or help me with the code?

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
  • Please post what you have tried and ask for help with a solution. Most people frown on doing somebody else's work, but are here to help. – Romain Hippeau May 13 '21 at 10:18
  • Many examples of how to split a string here: https://stackoverflow.com/questions/53849/how-do-i-tokenize-a-string-in-c – Retired Ninja May 13 '21 at 10:20
  • Your first problem is understanding what you want to do. Then you need to describe it. Neither is clear. A [mcve] with details about what is going wrong, what the output is, and what you would want the output to be is often useful. – Yakk - Adam Nevraumont May 13 '21 at 13:52

0 Answers0