输入提示信息:"Input a string:"
输入字符串用gets()
输出提示信息:"Inversed results:%s\n"
参考答案
#include <stdio.h>
#include <string.h>
#define N 80
void Inverse(char str[], char ptr[]);
int main()
{
char a[N],b[N];
printf("Input a string:");
gets(a);
Inverse(a,b);
printf("Inversed results:%s\n",b);
return 0;
}
void Inverse(char str[], char ptr[])
{
int len,i,j;
len = strlen(str);
for(i=0,j=len-1;str[i]!='\0';i++,j--)
{
ptr[j] = str[i];
}
ptr[j] = '\0';
}