
哪位高手帮我看一下这个程序的错误,连接两个字符串, 不用strcat 函数 谢谢
#include<stdio.h>voidmain(){chars1[80],s2[40];inti=0,j=0;printf("inputstring1:");scan...
#include<stdio.h>
void main()
{
char s1[80],s2[40];
int i=0,j=0;
printf("input string1: ");
scanf("%c",s1);
printf("\n");
printf("input string2: ");
scanf("%c",s2);
while(s1[i]!='\0')
i++;
while(s2[j]!='\0')
s1[i++]=s1[j++];
s1[i]='\0';
printf("The new string is:%s\n",s1);
}
其中 str1[i++]=str2[j++]; 展开
void main()
{
char s1[80],s2[40];
int i=0,j=0;
printf("input string1: ");
scanf("%c",s1);
printf("\n");
printf("input string2: ");
scanf("%c",s2);
while(s1[i]!='\0')
i++;
while(s2[j]!='\0')
s1[i++]=s1[j++];
s1[i]='\0';
printf("The new string is:%s\n",s1);
}
其中 str1[i++]=str2[j++]; 展开
1个回答
展开全部
scanf("%s",s1);
scanf("%s",s2);
%c是字符的格式。明白了么
scanf("%s",s2);
%c是字符的格式。明白了么
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询