post  Strings Confusion

SomeOneHackedMyName (17)   Link to this post
I just get lost with strings, I'm not even coding with it right now, I need some people to just explain it to me. Whenever I do try coding with it, only the first character makes it through or I get compiling errors reading:

could not convert `(&Spell)>std::basic_string<_CharT,_Traits,_Alloc>::operator= [with _CharT = char, _Traits=std::char_traits<char>,_Alloc=std::allocator<char>](((const char*)"Alex"))' to `bool'

I usually try to use the strings with conditional statements, like if's.

1
2
3
4
5
6
if(name="Alex"){
cout << "Hello, Alex." << endl;
}
else{
cout << "You're not Alex! Get off this computer!" << endl;
}
Last edited on
firedraco (2625)   Link to this post
You are using '=' instead of '=='.
SomeOneHackedMyName (17)   Link to this post
I'm gonna need a bit more information on strings than that =/
edited:
1
2
3
4
5
6
if(name=="Alex"){
cout << "Hello, Alex." << endl;
}
else{
cout << "You're not Alex! Get off this computer!" << endl;
}
Last edited on
Duoas (3510)   Link to this post
You're gonna have to give a bit more information than that if you want more help. The clip you've posted is fine.
mcleano (733)   Link to this post
Post the code you wrote which created that error above, if you still have i or can remember it.

This topic is archived - New replies not allowed.