cplusplus.com
C++ : Forum : Beginners : Strings Confusion
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs


post Strings Confusion

SomeOneHackedMyName (17)
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 (4744)
You are using '=' instead of '=='.
SomeOneHackedMyName (17)
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 (5977)
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 (922)
Post the code you wrote which created that error above, if you still have i or can remember it.
Topic archived. No new replies allowed.