Processing a user's input?
I am getting user input开发者_StackOverflow中文版 on the column, row number and data they want to put in that place. How would I go about breaking the user input into pieces ? The user input will always be in the COLUMN ROW DATA format so is there any delimiter statement that I can use ?
If your user input is a string in the format:
<col> <row> <data>
You can use the split() method on the space (" ") to get an array of strings.
For example
input = "3 2 100";
inputs = input.split(" ");
column = inputs[0]; // "3"
row = inputs[1]; // "2"
data = inputs[2]; // "100"
If this isn't what you're looking for then please elaborate your question.
精彩评论