标题:编译无法通过
只看楼主
DJY774692667
Rank: 1
等 级:新手上路
帖 子:21
专家分:7
注 册:2015-7-14
结帖率:90%
已结贴  问题点数:18 回复次数:2 
编译无法通过
int sf(char *s1, char *s2)
{ while(*s1==*s2){
  if(*s1==0)return 0;/*比较两个字符数组的大小*/
s1++;
s2++;
}
return (*s1-*s2);
}
#include<stdio.h>
#include<stdlib.h>
int main()
{
int sf(char *s1,char *s2);
char *s1,*s2;
int i.n,m;
for(i=1;i<3;i++)
printf("请输入第%d个数组长度\n",i);
scanf("%d %d",&n,&m);
s1=(char*)calloc(n+1,sizeof(char));
s1=(char*)calloc(m+1,sizeof(char));
scanf("%s\n%s",s1,s2);
sf(s1,s2);
}
2015-12-16 23:17
newdos
Rank: 9Rank: 9Rank: 9
等 级:禁止访问
威 望:6
帖 子:251
专家分:1169
注 册:2012-8-13
得分:3 
int i.n,m;   <----------i.n?

s1=(char*)calloc(n+1,sizeof(char));
s1=(char*)calloc(m+1,sizeof(char));

s1两次?
2015-12-16 23:44
期学者
Rank: 2
等 级:论坛游民
帖 子:9
专家分:20
注 册:2015-10-30
得分:15 
int sf(char *s1, char *s2)
{ while(*s1==*s2)
{
  if(*s1==0)return 0;/*比较两个字符数组的大小*/
s1++;
s2++;
}
return (*s1-*s2);
}
#include<stdio.h>
#include<stdlib.h>
int main()
{
int sf(char *s1,char *s2);
char *s1,*s2;
int i,n,m,a;
for(i=1;i<3;i++)
printf("请输入第%d个数组长度\n",i);
scanf("%d %d",&n,&m);
s1=(char*)calloc(n+1,sizeof(char));
s2=(char*)calloc(m+1,sizeof(char));
scanf("%s\n%s",s1,s2);
a=(int)sf(s1,s2);
if(a>0)
{printf("第一个字符大");}
else if(a==0)
{printf("两个字符一样大");}
else
{("第二个字符大");}

}
2015-12-17 09:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-460291-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.869913 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved