To the program work the way you expect, you need to initialize the str and str2 memory areas with the same values (say, with all zeroes, for example):
PHP Code:
(...)
char str[20];
char str2[20];
memset(str, 0, sizeof(str));
memset(str2, 0, sizeof(str2));
(...)
If you donīt initialize str and str2 with the same values, these areas will contain random values, so the memcmp comparison will not match, even if they both have some values in common (both begin with 'h','e','l','l','o', but you donīt know what each have after the 5 first characters, cause it is uninitialized memory).