0

How can declare a word?

For example : if i write the word "yes", do that thing...

26th Mar 2019, 2:59 PM
Eazy Think
Eazy Think - avatar
2 Respostas
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.
26th Mar 2019, 3:56 PM
Evan Skyberg
Evan Skyberg - avatar
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!"
26th Mar 2019, 4:18 PM
Vlad Serbu
Vlad Serbu - avatar