字符串逆序
#include <stdio.h>
#include <string.h>
int main(void)
{
char *src = "LiMing";
int len = strlen(src);
char *dest = (char*)malloc(len + 1);
char *d = dest;
char *s = &src[len-1];
while(len!=0)
{
*d++ = *s--;
len--;
}
*d = 0; //否则会乱码
//尾部要加\0
printf("dest = %s\n",dest);
return 0;
}