函数sstrcmp()的功能是对两个字符串进行比较。

来源:百度知道 编辑:UC知道 时间:2024/05/11 00:26:46
函数sstrcmp()的功能是对两个字符串进行比较。当s 所指字符串和t所指字符相等时,返回值为0;当s所指字符串大于t所指字符串时,返回值大于0;当s所指字符串小于t所指字符串时,返回值小于0(功能等同于库函数strcmp())。请填空。
#include <stdio.h>
int sstrcmp(char *s,char *t)
{while(*s&&*t&&*s==______)
{s++;t++; }
return ______;
}

告诉我原因,谢谢
*s-*t 或 *s-t[0] 或 s[0]-*t 或 s[0]-t[0] 或 (*s-*t) 或 (*s-t[0]) 或 (s[0]-*t) 或 (s[0]-t[0])
这才是return后的内容;不是0,也不是(*t-*s)

#include <stdio.h>
int sstrcmp(char *s,char *t)
{while(*s&&*t&&*s==*t) /*这里判断两个字符串是否相等*/
{s++;t++; }
return 0;
}
因为你的程序中只有一个return,再结合上下语句,也就是当两个字符串相等时返回0

return (*t-*s);
才对