问答题

请编一个函数fun(char*str),该函数的功能是把字符串中的内容逆置。
例如,字符串中原有的字符串为asdfg,则调用该函数后,串中的内容为gfdsa。
请勿改动主函数rllain和其他函数中的任何内容,仅在函数proc的花括号中填入所编写的若干语句。
试题程序:
#include<string.h>
#include<conio.h>
#include<stdio.h>
#define N 100
void fun(char*str)
char a[N];
FILE*out;
printf("Enter a string:");
gets(a);
printf("The original string is:");
puts(a);
fun(a);

main()
printf("The string after modified:");
puts(a);
strcpy(a,"Welcome!");
fun(a);
out=fopen("outfile.dat","w");
fprintf(out,"%s",a);
fclose(out);

【参考答案】

char ch;
int i,m,n;
i=0;
m=n=strlen(str)-1; ......

(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)