/*字符串逆序*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char* strrev(const char *);
int main(int argc , char *argv[])
{
printf("%s\n",strrev("helloworld!!"));
return 0;
}
char* strrev(const char *org)
{
int size = strlen(org);
char *tgt_p = NULL, *org_p = NULL;
char *tgt = (char *)calloc(sizeof(char),size+1);
tgt_p = tgt;
org_p = org + size - 1;
do
{
*tgt_p = *org_p;
++tgt_p;
--org_p;
}while(org <= org_p);
*(tgt + size) = '\0';
return tgt;
}
面试题目写一个字符串逆序函数strrev()
最新推荐文章于 2021-11-21 13:35:42 发布