两字符串重排相等 c语言

来源:百度知道 编辑:UC知道 时间:2024/06/30 02:58:18
写一个函数,判断两字符串是否重排相等

就追分

不知道理解的对不对,是不是判断两个字符串排列相等???

int func(char *desc, char *sour)
{
char *p1 = NULL, *p2 = NULL;

if (desc == NULL || sour == NULL)
{
return 0;
}

p1 = desc, p2 = sour;

while (*p1 != '\0')
{
if (*p1++ != *p2++)
{
printf ("not same\n");
return 0;
}
}

if (*p2 != '\0')
printf ("no same\n");
else
printf ("same\n");
return 0;
}