fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. string whole, part;
  6. whole = "TestString";
  7. part = "Test";
  8. cout << "Comp whole vs part: " << (whole.compare(0, part.size(), part)) << endl;
  9. cout << "Comp part vs whole: " << (part.compare(0, whole.size(), whole)) << endl;
  10. return 0;
  11. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
Comp whole vs part: 0
Comp part vs whole: -6