关于函数strrev的实现
#include <syslib.h>
#include <string.h>
main()
{
char *s="Welcome To Beijing";
clrscr();
textmode(0x00); // 6 lines per screen
printf("%s\n%s",s,strrev(strdup(s)));
getchar();
return 0;
}
/**
* @file strrev.c
* @brief
*/
#include <stdio.h>
#include <string.h>
char *strrev(char *s)
{
char *h, *t;
char c;
h = s;
t = s + strlen(s) - 1;
printf("%h=%p,t=%p\n", h, t);
while (h < t) {
c = *h;
*(h++) = *t;
*(t--) = c;
}
return s;
}
int main(int argc, char *argv[])
{
char s[] = "012345678";
printf("[%s]\n", strrev(s));
return 0;
}