Concept

How does strcmp() compare the contents of two strings in C?

ComputerScienceOne / Comparisons

"The C string library provides a standard comparator function to compare strings based on their content:\n\nint strcmp(const char *a, const char *b);\n\nThe function takes two strings and returns an integer based on the lexicographic ordering of a and b. If a precedes b, strcmp() returns something negative. It returns zero if a and b have the same content. Otherwise it returns something positive if b precedes a. Some examples:\n\n1 int x;\n\n2 x = strcmp(\"apple\", \"banana\"); //x is negative\n\n3 x = strcmp(\"zelda\", \"mario\"); //x is positive"

Related Ideas

How does strcmp() compare the contents of two strings in C? | ComputerScienceOne | Bifalgorithm | Bifalgorithm