[urgent] how to get the users input to be stored in 1 out of x variables

Making a game of checkers on C++ win32, visual studio

when i want a piece to move, i type:

cout << "What piece do you want to move? (C4)" << endl;

i type in 'cin' after to get the players input, but how do i get it to store the players input in a certain variable?
im going to have a list of variables:
1
2
3
string a1
string a2
string a3

etc

so if the user types in a2, it automatically goes to that variable and then asks the user "where do you want the piece to be moved to?".
Last edited on
well firstly you would want to cout your question, not cin it.

http://www.cplusplus.com/doc/tutorial/files/
Last edited on
Instead of having 3 separate "a" variables, use an array:
 
string a[3];


Now if the user types in "a3", you have to extract the "3" character, convert it to an integer and use it to index into the array.

By the way, cin is the standard input stream and shouldn't be used for output, so you probably want:
 
cout << "What piece do you want to move? (C4)" << endl;

crap sorry, silly mistake
how do you extract that character '3'? sorry, im a beginner
have a read of the link i pasted.
ok, so that link explains how to write to external text files, read them, etc. is this required to extract the character from the string the player inputs?
Topic archived. No new replies allowed.