谁知道if里面的条件怎么用其他方式表达出来,我不想要这个,可以用其他方式表达出这个意思吗。有的请详细说下,谢谢啦!
c里面字符串比较用strcmp。或者自己写个函数比较。
C++字符串可以用string类型,string a,b。string类型可以直接==比较,if(a==b)
可以自己写一个
int Mystrcmp(char* s1, char* s2) {
while (*s1 != '\0'&&*s2 != '\0') {
if (*s1 != *s2) {
return *s1 - *s2;
}
else {
s1++;
s2++;
}
}
return *s1 - *s2;
}