Blubb: Frage zu strcmp

Beitrag lesen

Hallo,

wenn ich die Quellen von PHP richtig lese, dann funktioniert die API Funktion strcmp() so:

  
ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */  
{  
	int retval;  
  
	retval = memcmp(s1, s2, MIN(len1, len2));  
	if (!retval) {  
		return (len1 - len2);  
	} else {  
		return retval;  
	}  
}  
/* }}} */  

Und in der man page von memcmp steht:
"The memcmp() function returns zero if the two strings are identical, otherwise returns the difference between the first two differing bytes (treated as unsigned char values, so that \200' is greater than \0', for example).  Zero-length strings are always identical."

Grüße