This is a followup to my previous question.
Parsing file names from a character array
The answer was relevant but I am still having trouble. When the strings are split, I can’t seem to get them to output correctly to my error log either as a string or cstring and to be honest, I don’t completely understand how his answer works. So does anyone have a further explanation of the answer the gentleman provided. How would I split the character array into a larger number of strings rather than just writing them all out. This was the answer.
std::istringstream iss(the_array);
std::string f1, f2, f3, f4;
iss >> f1 >> f2 >> f3 >> f4;
Imagine I have 30 different strings. Surely, I can’t write f1, f2….f30.
Any advice on how to do this?
You can even avoid explicit for loops and try a way that is more natural to modern C++ if you will.
This is the obvious way of dealing with a scenario like “I have 30 different strings”. Store them all somewhere, an std::vector is probably suitable, depending on what you might want to do with the filenames. This way you don’t need to give every string a name (f1, f2, …), you can just refer to them by indices of the vector if needed, for example.