you simply type what you want the string to be betwen the "", to display he string you do cout<< string1'
one way to see if a string is equale is if ( strcmp ( string1, string2) == 0 )
or try this if (str1.compare(str2) == 0) first on may just be C... been so long havnt touched either in about 2 years =P
Here, this was the very very very very first thing I ever did in c++, maybe it can help you out with basics
Note: it does have some odd glitch on some computers where the computer will attack for like 29382938928392 dmg... no idea why it does that, simply running it in compatibility mode will fix it 50% of the time lol. Yet it only does that on SOME comps... on both mine.. it works perfectly.
You need to include the <string> library, NOT the <cstring> library (that library just contains a bunch of functions for dealing with C-style strings, which you should avoid using), to use C++ string objects. And to compare string objects, just use the == operator.
int main() { string string1 = ""; string stringa = "";
...
...
how do i set values for strings, display strings once i have values for them, and check if a string is the same as another string?
you simply type what you want the string to be betwen the "", to display he string you do cout<< string1'
one way to see if a string is equale is if ( strcmp ( string1, string2) == 0 ) or try this if (str1.compare(str2) == 0) first on may just be C... been so long havnt touched either in about 2 years =P
@Molsterr: Go
yeah i know i can define the string there, but what if i want the string defined by an entry from the user?
cin >> yourstringvar;
Here, this was the very very very very first thing I ever did in c++, maybe it can help you out with basics
Note: it does have some odd glitch on some computers where the computer will attack for like 29382938928392 dmg... no idea why it does that, simply running it in compatibility mode will fix it 50% of the time lol. Yet it only does that on SOME comps... on both mine.. it works perfectly.
You need to include the <string> library, NOT the <cstring> library (that library just contains a bunch of functions for dealing with C-style strings, which you should avoid using), to use C++ string objects. And to compare string objects, just use the == operator.
There is more reference to strings in the web than you could ever read in your entire life :P
http://anaturb.net/C/string_exapm.htm
http://www.cplusplus.com/reference/string/string/