0
How can declare a word?
For example : if i write the word "yes", do that thing...
2 Respuestas
0
You would use the std::string to assign a text variable. To save a variable with text without an array, you would put
std::string "Word";
Let's say you want to make an array identified A. You should use
std::string A[26];
Problem, though. You have to insert every value manually, so you would have either 26 lines of code or one really long line assigning words or letters to their respective values.
0
A word is an array of characters, so you can use character arrays:
char s[20] = "yes";
You can do what you want like:
cin >> s;
if (strcmp(s, "yes") == 0)
cout << "You have answered yes!"