| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 937 人关注过本帖
标题:编译无法通过
只看楼主 加入收藏
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
快速回复:编译无法通过
数据加载中...
 
   



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

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