程序:
#include<stdio.h>
#include <string.h>
int Strcmp(char* c ,char* c1);
int main(){
char c [] = "hello";
char c1 [] = "hlloE";
char *p,*p1;
p = c;
p1 = c1;
int N = 0;
N = Strcmp(p,p1);
printf("%d",N);
return 0;
}
//字符串c==字符串c1 返回0; >返回1; <返回差值;
int Strcmp(char *c,char *c1){
int i = 0,N=-1;
while (c[i]!='\0'&&c1[i]!='\0')
{
if(strlen(c)!=strlen(c1)){
return N;
}
N = c[i]-c1[i];
if (N)
{
break;
}
i++;
}
return N;
}
日期: 2021-12-8