下列给定程序中,函数fun的功能是:将s所指字符串的正序和反序进行连接,形成的新串放在t所指的数组中。
例如,当s所指字符串为“ABCD”时,t所指字符串中的内容应为“ABCDDCBA”。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<string.h>
/*************found****************/
void fun(char s,char t)
int i,d;
d=strlen(s);
for(i=0;i<d;i++)
t[i]=s[i];
for(i=0;i<d;i++)
t[d+i]=s[d-1-i];
/************found**************/
t[2*d-1]=’\0’;
main()
char s[100],t[100];
printf("\nPlease enter string S:");
scanf("%s",s);
fun(s,t);
printf("\nThe result is:%s\n",t);