C examples for String:Compare
Strncmp() function compares up to a given number, n, of characters of the two strings.
#include <stdio.h> #include <string.h> int main(void) { char str1[] = "The quick brown fox"; char str2[] = "The quick black fox"; if (strncmp(str1, str2, 10) <= 0) printf("\n%s\n%s", str1, str2); else// w w w . j ava2s . c om printf("\n%s\n%s", str2, str1); return 0; }