C++ Code
1
2 3 4 5 6 7 8 9 10 11 12 |
int strcmp(const char *dest, const char *source)
{ assert((NULL != dest) && (NULL != source)); while (*dest && *source && (*dest == *source)) { dest ++; source ++; } return *dest - *source; /*如果dest > source,则返回值大于0,如果dest = source,则返回值等于0,如果dest < source ,则返回值小于0。*/ } |