1 #include <stdio.h>
2 #include <string.h>
3
4 char *revstr(char *str, size_t len)
5 {
6 char *start = str;
7 char *end = str + len - 1;
8 char ch;
9
10 if (str != NULL)
11 {
12 while (start < end)
13 {
14 ch = *start;
15 *start++ = *end;
16 *end-- = ch;
17 }
18 }
19 return str;
20 }
21
22 int main(void)
23 {
24 char *p;
27 p = revstr(string, strlen(string));
28 printf("%s\n",p);
29
30 }
2 #include <string.h>
3
4 char *revstr(char *str, size_t len)
5 {
6 char *start = str;
7 char *end = str + len - 1;
8 char ch;
9
10 if (str != NULL)
11 {
12 while (start < end)
13 {
14 ch = *start;
15 *start++ = *end;
16 *end-- = ch;
17 }
18 }
19 return str;
20 }
21
22 int main(void)
23 {
24 char *p;
25 char string[] = "\0";
scanf("%s", string);
2627 p = revstr(string, strlen(string));
28 printf("%s\n",p);
29
30 }