这是函数题怎样将字符串连接呢!大家看看吧!谢谢!
1、程序包含一个主函数和一个函数fun(),函数fun()的功能是:把主函数中输入的字符串str2接在字符串str1的后面。例如,str1=“How do”,str2=“you do”,输出结果为“How do you do?”.2、请编写函数fun,其功能是:计算并输出给定数组(长度为9)中吗,每两个相邻元素的平均值的平方根之和。
程序代码:#include <stdio.h>
void fun(char * str1, char * str2) {
// #include <string.h>
// strcpy(str1, str2);
while(*str1)
str1++;
while(*str2)
*str1++ = *str2++;
str1 = '\0';
}
int main(void) {
char str1[81] = "How do ", str2[81];
gets(str2);
fun(str1, str2);
printf("%s\n", str1);
return 0;
} /* Output:
you think?
How do you think?
Process returned 0 (0x0) execution time : 3.578 s
Press any key to continue.
*/第一题的,第二题没看懂意思。