C++ 字符串比较函数:stringCompared 实现详解
#include\x20
int\x20stringCompared(char\x20p1,\x20char\x20p2)\x20{ \x20\x20while\x20(p1\x20&&\x20p2\x20&&\x20p1\x20==\x20p2)\x20{ \x20\x20\x20\x20p1++; \x20\x20\x20\x20p2++; \x20\x20} \x20\x20return\x20p1\x20-\x20p2; }
int\x20main()\x20{ \x20\x20char\x20s1[]\x20=\x20"hello"; \x20\x20char\x20s2[]\x20=\x20"hella"; \x20\x20int\x20result\x20=\x20stringCompared(s1,\x20s2); \x20\x20std::cout\x20<<\x20result\x20<<\x20std::endl; \x20\x20return\x200; }
原文地址: https://www.cveoy.top/t/topic/onNk 著作权归作者所有。请勿转载和采集!