//这是系统库的实现 int strcmp(const char* src, const char* dest) { int rtn = 0; while(!(rtn = *(unsigned char*)src - *(unsigned char*)dest) && *dest) { ++src; ++dest; } if (rtn < 0) { rtn = -1; }else if (rtn > 0) { rtn = 1; } return rtn; }
结果:相等返回0,src 大于dest返回1,src小于dest返回-1.。