question on strcmp


Hi

1 is true and 0 is false
so why do the following two lines of code indicate 0 and 1?
should they not output 1 and 0 respectively, since the first line is a match, hence true?
1
2
std::cout << "Value of strcmp(\"gogo\",\"gogo\")" << strcmp("gogo","gogo") << std::endl;
std::cout << "Value of strcmp(\"gostop\",\"gogo\")" << strcmp("gostop","gogo") << std::endl;


Last edited on
zero indicates equality, and non zero indicates inequality.
Also, see http://www.cplusplus.com/reference/cstring/strcmp/
for meaning of return value.
Topic archived. No new replies allowed.