int memcmp(const void *str1, const void *str2, size_t n);
check the size of a string and string2 and return a value
less 0 string1 lesser than string2 equal 0 string1 equal string2 greater 0 string1 greater than string2
#include <stdio.h> /* including standard library */ //#include <windows.h> /* uncomment this for Windows */ #include <string.h> #define MAX 42 int main ( void ) { char string1[MAX]="Teststring"; char string2[MAX]="test"; int i; i = memcmp ( string1, string2, MAX ); if (i < 0) { printf("String:\"%s\" is greater as String:\"%s\"\n", string1, string2); /* is greater */ } return 0; }
output: user@host:~$ ./memcmp String:"Teststring" is greater as String:"test"