C++ string comparison

66 Views Asked by At
#include<iostream> 
using namespace std; 
int main() 
{ 
    string s1("22"); 
    string s2("21"); 
    cout<<(s1 < s2)<<endl;
    cout<<("22" < "21")<<endl;
return 0; 
} 

Try running the c++ code.

Why does the output give 0 and 1? and not the same answer. I might ask is s1 and "22" different, if so how?

0

There are 0 best solutions below