D
Deleted User
Guest
I am working on a text based program written in C++, and I am trying to implement a command reading function but I am unsure where to start. I have tried Google but Google has yielded little to no results detailing this problem. For example I am trying to make a program will ask the user a question and then read the character string the user recorded and try to find a valid verb or adjective and based upon this information it would give the user a answer. I was thinking I could use a if statement and do something like this
but not only does this lack flexibility, it also will only read the first part of the string, as strings only record a string of characters and are broken by white-space. I was also thinking I could have the user record their input in stages such as verb adjective then noun but this would only work in certain situations. It is a puzzling dilemma to say the least and I was hoping someone knew a way to implement this in a way that would work. Thank you for any help that you are willing to provide.
Code:
if(Command == "(text)")
{
cout << "(output)" << endl;
}
but not only does this lack flexibility, it also will only read the first part of the string, as strings only record a string of characters and are broken by white-space. I was also thinking I could have the user record their input in stages such as verb adjective then noun but this would only work in certain situations. It is a puzzling dilemma to say the least and I was hoping someone knew a way to implement this in a way that would work. Thank you for any help that you are willing to provide.






