String: equals : string compare « String « C++






String: equals

  
 
#include <iostream.h>
#include <string>
using std::string;

main(void)
{
   string s1 = "abcdefghijk", s2 = "1234567890", s3,s4,s5;

   s3=s1+s2;
   cout << s3 <<endl;

   s4=s3;
   if (s4==s3) 
      cout << " s4==s3 is true\n";

   return(0);
}

/* 
abcdefghijk1234567890
 s4==s3 is true

*/
        
    
  








Related examples in the same category

1.string overloaded equality and relational operators
2.Compare string ignoring the case
3.Compare sub string: string4.compare( 0, string2.length(), string2 )
4.Use == > and < to compare strings
5.Use string.compare to compare two strings
6.Compare strings by index: string1.compare( 2, 5, string3, 0, 5)
7.Set with functor for string comparison
8.return true if c1 < c2 (ignoring case), false otherwise
9.Use std::lexicographical_compare to compare two char arrays
10.Compare strings
11.return true if c1 equals c2 (regardless of case), false otherwise