Hi,
I have a string *input;
and that variable is initalized with getInput();
. I initialize input in setup()
. setup()
is run once. this is where my problem is: I'm looking for a better logic that let me initialize input
without getting a prompt which came from getline(cin, line)
that is inside getInput();
string* Controls::getInput(){
static string sentence[4];
string line;
int i = 0;
cout << ":>_";
getline(cin, line);
transform(line.begin(), line.end(), line.begin(), ::tolower);
stringstream ss(line);
for (int x = 0; x < 4; x++){
sentence[x] = "null";
}
while (ss.good()) {
ss >> sentence[i++];
}
while (i < 4){
sentence[i++] = "null";
}
return sentence;
}
How should I proceed??