1
int main() {
  if("abc" < "a")
     cout << 1 << "\n";
  else 
      cout << 0 << "\n";
  return 0;
}

Output: 1

Why 1 is coming in the output?

Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
  • `"aba" < "a"` compares the **addresses** of the two string literals. If you must use C-style strings, use `std::strcmp` to test for equality. Or use `std::string("aba") < "a"`. – Pete Becker Aug 11 '20 at 15:42

0 Answers0