实现函数strcat的功能的程序

大扣子 2011-09-10 02:11:00
#include <stdio.h>
main()
{
int str1[100];
int str2[100];
int i=0,j=0;
printf("输入两个字符串\n");
scanf("%s%s",str1,str2);
getchar();
while(str1[i]!='\0')
{
i++;
}
while(str1[i]=str2[j]!='\0')
{
j++;
i++;
}
printf("输出新str1%s",str1);
}


编译无错误,可以运行时候输入两个字符串后回车就停止工作,怎么回事,,,大虾求解
...全文
143 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
大扣子 2011-09-10
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wxwlll 的回复:]
引用楼主 o107704785 的回复:
#include <stdio.h>
main()
{
int str1[100];
int str2[100];
int i=0,j=0;
printf("输入两个字符串\n");
scanf("%s%s",str1,str2);
getchar();
while(str1[i]!='\0')
{
i++;
}
while(s……
[/Quote]



是连接功能
imeuyniy 2011-09-10
  • 打赏
  • 举报
回复
    char str1[100];
char str2[100];
int i=0,j=0;
printf("???????\n");
scanf("%s%s",str1,str2);
while(str1[i++]!='\0')
;
i--;
while(str2[j]!='\0')
{
str1[i++]=str2[j++];
}
str1[i]='\0';
printf("???str1:%s",str1);
wxwlll 2011-09-10
  • 打赏
  • 举报
回复
[Quote=引用楼主 o107704785 的回复:]
#include <stdio.h>
main()
{
int str1[100];
int str2[100];
int i=0,j=0;
printf("输入两个字符串\n");
scanf("%s%s",str1,str2);
getchar();
while(str1[i]!='\0')
{
i++;
}
while(str1[i]=str2[j]!='\0')
……
[/Quote]
你实现的是字符串拷贝函数,应定义char型!1楼的说的很对!我在2楼中写的代码,也能
wxwlll 2011-09-10
  • 打赏
  • 举报
回复

#include <stdio.h>
main()
{
int str1[100];
int str2[100];
int i=0,j=0;
printf("输入两个字符串\n");
scanf("%s%s",str1,str2);
while(str1[i]!='\0')
{
i++;
}
i-=1;
while(str2[j]!='\0')
{
str1[i++]=str2[j++];
}
printf("输出新str1:%s",str1);
}
qq120848369 2011-09-10
  • 打赏
  • 举报
回复
int str1[100];
int str2[100];

69,364

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧