C语言课程设计

写一函数,连接两个字符串。例如:
输入字符串1:hello↙
输入字符串2:world↙
连接后的字符串:helloworld

第1个回答  2008-07-07
#include <stdio.h>
main()
{
char x,y;
printf("%c",x);
scanf("%c",&x);
printf("%c",y);
scanf("%c",&y);
printf("%c",x&&y);
}

你只要在运行画面出现printf("%c",x);的时候输入x的值,也就是hello
在运行画面出现printf("%c",y);的时候输入y的值,也就是world
就好了 就会出现2个字符连在一起了
第2个回答  2008-07-11
晕,要是可以用C的标准函数还出这道题干什么了?

#include <stdio.h>

char * __strcat(char *str1, char *str2);

main()
{
char str1[100], str2[50];
printf("Enter Str1 : ");
gets(str1);

printf("Enter Str2 : ");
gets(str2);

__strcat(str1,str2);

printf("StrCat : %s\n",str1);
getch();

return 0;
}

char * __strcat(char *destination, char *str)
{
while(*destination != '\0')
{
destination++;
}

while(*str != '\0')
{
*destination++ = *str++;
}

return destination;
}

/*
输入字符串1:hello ↙
输入字符串2:world!↙
连接后输出 :hello world!
*/本回答被网友采纳
第3个回答  2008-07-07
include<stdio.h>
void main()
{
char a[20],b[8];
printf("ENTER");
scanf("%s",&a);
printf("ENTER AGAIN");
scanf("%s",&b);
printf("%s",strcat(a,b));
}
第4个回答  2008-07-07
第2位回答不错,但用strcat前先定义其函数~