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 /* including standard library */
//#include /* uncomment this for Windows */
#include
#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"