//There were always errors at the beginning, and the reverse order could not be printed. It turned out to be because it sizeof(src)/sizeof(src[0]);
was used find the length of the string.
#include <stdio.h>
#include <string.h>
char *reserve(char *src)
{
int i;
int len = strlen(src);
int n = len/2;
char tmp;
for(i = 0;i < n; i++){
tmp = src[i];
src[i] = src[len-i-1];
src[len-i-1] = tmp;
}
return src;
}
int main()
{
char str[20];
printf("Please input a string:\n");
scanf("%s",str);
printf("The reserved string is:\n%s",reserve(str));
return 0;
}