7.13编写一程序将两个字符串连接起来,不使用stracat函数
输入的时候,注意字符串的长度。
#include<stdio.h>//7.13 编写一个程序,将两个字符串连接起来,不要用strcat函数。
int main()
{
char c1[20],c2[20];
int i=0,j=0;
printf("Input string1:");
gets(c1);
printf("Input string2:");
gets(c2);
while(c1[i]!=‘\0‘){
i++;
}
while(c2[j]!=‘\0‘){
c1[i++]=c2[j++];
}
c1[i]=‘\0‘; //给出c1字符串的结束符,此时,c1和c2的长度和可以是20
puts(c1);
return 0;
}
7.13编写一程序将两个字符串连接起来,不使用stracat函数
原文:http://www.cnblogs.com/Allen-win/p/7221540.html