# include <stdio.h>
# include <stdlib.h>
# include <string.h>
int my_strlen(char *str)
{
if(*str == '\0')
return 0;
else
return 1+my_strlen(str+1);
}
char *reverse_string(char *str,int len)
{
if(len > 1)
{
char tmp = *str;
*str = *(str+len-1);
*(str+len-1) = tmp;
reverse_string(str+1,len-2);
}
return str;
}
int main()
{
char str[] = "abcdefgh";
int len = strlen(str);
reverse_string(str,len);
printf("%s\n",str);
system("pause");
return 0;
}
文章标题
最新推荐文章于 2022-05-12 11:32:07 发布