Analyzing input string

Hello,

How do I analyze input string from user?

For example, I want "XXXXX" in one line to be parsed each character on its own.

Originally, I want to fill a 2D array, so I created 2 nested for-loops but I couldn't manage to make the user able to fill the array as follows:
XYZAB
XXXXX
XXXXX

So, the array would be of size 3 * 5, and each line the user types 5 characters (the X's) and, for example, first line when he hits enter, array[0][0-4] would be filled with: X, Y, Z, A, B.

Should I use sscanf? What and how should I use some function to do this?

Thank you.
This should help:

1
2
3
4
5
string input = "";
getline(input, cin);

for (unsigned i = 0; i < input.length(); ++i)
 my_array[i] = input[i];
Topic archived. No new replies allowed.