N
Nawaz
how to compare two string written below.
string str1;
string str2;
thanks for answer;
string str1;
string str2;
thanks for answer;
Nawaz said:how to compare two string written below.
string str1;
string str2;
Geoff said:Compare two strings or compare two pointers to strings?
Nawaz ha scritto:
str1 == str2
--
Christian Hackl
(e-mail address removed)
Milano 2008/2009 -- L'Italia chiamò, sì!
Nawaz said:no sir in real I want a answer of a question that the char pointer
can compare by strcmp like this :
char * str1;
char * str2;
strcmp(str1,str2);
but why we can not compare two string of string datatype in this way;
string str1;
string str2;
a) you can: strcmp( str1.c_str(), str2.c_str() );
b) why would you want to that? After all:
str1 < str2
is equivalent to
strcmp( str1.c_str(), str2.c_str() ) < 0
Best
Kai-Uwe Bux
a) you can: strcmp( str1.c_str(), str2.c_str() );
b) why would you want to that? After all:
str1 < str2
is equivalent to
strcmp( str1.c_str(), str2.c_str() ) < 0
Nawaz said:because I want a valid logical answer that the char pointer is a
string
char * str //string
and
string str //string
so what is the defference between them?
Geoff said:Yes, as the thread has shown, my crystal ball was seeing something
along the C vs C++ string management.
a) you can: strcmp( str1.c_str(), str2.c_str() );
Nawaz said:because I want a valid logical answer that the char pointer is a
string
char * str //string
and
string str //string
so what is the defference between them?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.