Loading...
Select Version
&pagelevel(4)&pagelevel
Definition | #include <string.h> int strcmp(const char *s1, const char *s2);
"circle" is lexically less than "circular", | ||
Return val. | < 0 = 0 > 0 | s1 is lexically less than s2. s1 and s2 are lexically equal. s1 is lexically greater than s2. | |
Note | Strings terminated with the null byte (\0) are expected as arguments. | ||
Example | The following program searches the name list list for an input name: #include <stdio.h> #include <string.h> char *list[] = {"anne", "peter", "walter", "john" }; int main(int argc, char *argv[]) { int j, i = 0; while((i <= 3) && (j = strcmp(argv[1], list[i++]))); if (j == 0) printf("The candidate is already known!\n"); else printf("This is a new candidate!\n"); return 0; } | ||
See also | strncmp |