Difference between revisions of "CPP/Strings/Compare"

From ProgrammingExamples
< CPP
Jump to: navigation, search
(Created page with '==CompareStrings.cpp== <source lang="cpp"> #include <iostream> #include <string> using namespace std; int main(int argc, char *argv[]) { string Hello = "Hello"; string Go…')
 
 
(No difference)

Latest revision as of 07:52, 23 June 2010

CompareStrings.cpp

#include <iostream>
#include <string>
 
using namespace std;
 
int main(int argc, char *argv[])
{
  string Hello = "Hello";
  string Goodbye = "Goodbye";
 
  cout << Hello.compare(Goodbye) << " (should be != 0)" << endl;
  cout << Hello.compare(Hello) << " (should be == 0)" << endl;
  cout << Hello.compare("Hello") << " (should be == 0)" << endl;
 
  return 0;
}