#include <stdio.h>
void reverse(char *s)
{
int len = 0;
char *p = s;
while(*p != '\0')
{
len++;
p++;
}
int i= 0;
char temp;
while(i<=(len/2-1))
{
temp = *(s+i);
*(s+i) = *(s+len-1-i);
*(s+len-1-i) = temp;
i++;
}
}
int main()
{
char test[1000];
printf("please input string:\n");
scanf("%s",test);
reverse(test);
printf("%s\n",test);
}
网友评论