字符串逆序

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 int main()
 5 {
 6     char *src="hello,world";
 7     char *dest,*d,*p;
 8     int len,i;
 9     len=strlen(src);
10     dest=(char *)malloc(len+1);
11     p=&src[len-1];
12     d=dest;
13     while(len--!=0)
14         *d++=*p--;
15         //*(d++)=*(p--);
16     *d='\0';
17     printf("%s",dest);
18     return 0;
19 }

 

posted @ 2020-03-08 18:14  wydxry  阅读(196)  评论(0编辑  收藏  举报
Live2D