- #include <stdio.h>
-
#include <string.h>
-
-
char *myStrreverse(char *s);
-
-
int
-
main(void)
-
{
-
char s[] = "hello";
-
char *r = myStrreverse(s);
-
printf(r);
-
-
return 0;
-
}
-
-
char *
-
myStrreverse(char *s)
-
{
-
if (NULL == s)
-
return NULL;
-
-
if (*s) {
-
char *h, *t;
-
-
h = s;
-
t = s + strlen(s) - 1;
-
-
while (h < t) {
-
char tmp;
-
-
tmp = *h;
-
*h = *t;
-
h++;
-
*t = tmp;
-
t--;
-
}
-
}
-
-
return s;
- }