comparing strings

Why is this true? z comes after a in alphabet and also if its being compared by size the 1st string is bigger that way also

 
  bool c = "zfff"<"af";


Can somebody explain this to me please?
What language is this?

You're not comparing strings, if that's what you think you're doing, you're comparing two "const char *"

To compare strings in c, you'd have to use strcmp() family, e.g.

bool c = strcmp("zfff", "af");
In C++ you'd use proper string objects with operator<

1
2
3
4
      bool c = strcmp("zfff", "af"); // comparing strings
	bool d = std::string("zfff") < std::string("af"); // comparing strings
	bool J = ("zfff" < "af"); // comparing addresses - J for Java, get it? Ha ha
Thanks a lot for answer :) That was supposed to be c++ code. It was from Bjarne Stroustrup's : Programming -- Principles and Practice Using C++, 1 exercise where i had to correct errors in code and i just didnt understand how is this really working.
Topic archived. No new replies allowed.