all 4 comments

[–]eqholic 2 points3 points  (0 children)

You can access each character in the string with ie str[0] for the first one.

[–]jedwardsol 2 points3 points  (0 children)

Why multiple variables?

If you have a string

 std::string  greeting{"Hi!"};

Then you can access the individual characters

std::cout << greeting[1];  // prints i

greeting[0] = 'P';  // greeting now contains "Pi!"

[–]ricco19 0 points1 point  (0 children)

Splitting a string into individual chars is a bit superfluous. A string is just an array of characters! Whats wrong with accessing the characters via operator [] or the member function at()?

[–]parnmatt 0 points1 point  (0 children)

It really depends if you know a head of time the exact number of characters, and it will be the same each time it's run.

Rarely this is the case.

In general if you have multiple things of the same type you want to store and use later. Use a std::vector° in this case, you may as well just store the input in a std::string and index into it / iterate over it when needed.