예제 |
#include <stdio.h>
#include <string.h>
int main( void)
{
char *ptr1 = "forum";
char *ptr2 = "forum";
char *ptr3 = "forum.falinux";
char *ptr4 = "falinux";
char *ptr5 = "com";
printf( "%s with %s = %dn", ptr1, ptr2, memcmp( ptr1, ptr2, strlen(ptr1)));
printf( "%s with %s (ptr1 size)= %dn", ptr1, ptr3, memcmp( ptr1, ptr3, strlen(ptr1)));
printf( "%s with %s (ptr3 size)= %dn", ptr1, ptr3, memcmp( ptr1, ptr3, strlen(ptr3)));
printf( "%s with %s = %dn", ptr1, ptr4, memcmp( ptr1, ptr4, strlen(ptr1)));
printf( "%s with %s (ptr1 size)= %dn", ptr1, ptr5, memcmp( ptr1, ptr5, strlen(ptr1)));
printf( "%s with %s (ptr5 size)= %dn", ptr1, ptr5, memcmp( ptr1, ptr5, strlen(ptr5)));
return 0;
}
|