Help with input handling.
For my final, I have to do an organizational chart using linked lists. Users have to be able to add people to the list, delete people, change information, blah blah blah. The problem is the way the user enters his information. Commands are of the format (command letter)(number), or for example, "insert at line three" looks like "I3".
Right now, I am using strings to store input, and doing a switch statement based on the first character. I am then passing the second character to the relevent function.
My switch statement:
As you can see from my comment, there is a problem: this method only works for numbers 1-9. C23 would currently be the same as C2, because I'm only looking at the second character.
void handleinput(string input)
command = input;
chart.insert(input - '0'); //only works for single digits
chart.change(input - '0');
chart.del(input - '0');
I don't know how to tokenize these strings, if it's even possible. There is NO space or other character between command and number.
If you know of a more elegant way to go about this, please help me.