0
How do you set variables equal to letters or words?
I've learned how to set and manipulate the value of variables but whenever I change the value to anything other than a number, there's an error.
6 odpowiedzi
+ 3
Yo so you are declaring an integer which can only be a whole number but you are trying to assign a string too it. You want to use an std::string. Lookup up how to use the string class and you can get this working.
+ 2
If you can post an example of what you are trying to do it will help.
+ 1
It’s because of the data type. It makes room in the memory for an int or char or whatever so you can’t just change it to a string it won’t fit.
+ 1
int x;
cin >> x;
if x == "this" {
cout << "that" << endl;
}
else {
cout << "what?" << endl;
+ 1
Ah! Thanks!
0
@Arthur Tripp So is there a data type that WILL let me do this?