How to egalise two strings
-
OK, just to see if i have caught what you said: I should use == to compare if string s1 has the same content with string s2. That´s it? Because I already have tried that and it doesn´t work...:((
-
OK, just to see if i have caught what you said: I should use == to compare if string s1 has the same content with string s2. That´s it? Because I already have tried that and it doesn´t work...:((
garfaoui wrote:
I should use == to compare if string s1 has the same content with string s2. That´s it?
exactly. but be careful, the operator must be the overload of std::string class. in the expression
s1 == s2
, if s1 is of type std::string, the code actually means to the compilers1.operator==(s2)
(calling then the functionbool std::string::operator==(const std::string&)
). but if s1 is a basic C-Style string (a char* basically), the compiler will try to compare the addresses, not the string contents... the context is exactly the same while using theoperator !=
. so, can you please post a relevant (but small) piece of code which can reproduce the error ? also, specify to us the type of all the variables used, and which error you get (if it is a compiler error, linker error, or run-time error), and its message.
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
Hello, I would like to compare two strings: i used:
if (s1==s2) {
I have no problem to compile, but even when s1=s2 it doesnt work... -
Oula je ne suis pas du tout enervé, choqué, ou autre. Je bois les paroles de tous ceux qui postent un message sur ce forum car je n´ai a mon actif ke 30h de langage c++. Je n´y connais pas grand chose. :) Je suis actuellement en stage et je dois realiser ce programme. Cela fait maintenant une semaine que je suis dessus, et je sens qu´il est tout près d´aboutir. Désolé si ma réponse a pu paraitre sèche, ce n´etait pas du tout l´esprit du message. C´est l´effet message ecrit qui ne transcrit pas le ton de la voix. :)
-
Francais et en stage au Portugal ?
Don't follow any man spiritually, don't do anything that will get you in sh*t if god is real - Bradml[^]
-
Te laisse pas impressioner par Tox, il est dur, mais très très fort. ;P
Don't follow any man spiritually, don't do anything that will get you in sh*t if god is real - Bradml[^]
-
Ne t´inquète pas! En tout cas il m´a bien aidé! C´est par rapport au repertoire de l´executable que tu as vu que j´étais au Portugal?
non, par rapport a ton profil ^^ @Régis, merci pr la petite note d'humour... "il est tres tres fort", c'est a double tranchant ca ;P
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
Ne t´inquète pas! En tout cas il m´a bien aidé! C´est par rapport au repertoire de l´executable que tu as vu que j´étais au Portugal?
-
non, par rapport a ton profil ^^ @Régis, merci pr la petite note d'humour... "il est tres tres fort", c'est a double tranchant ca ;P
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]