小编Amo*_*ngh的帖子

用递归反转c中的字符串

我已编写代码来反转c中的字符串......它工作正常,但我无法在main()函数中返回反向字符串.

#include<stdio.h>

main()
{
  char a[17]="abcdefg";
  reverse(a);
  printf("\n");
  system("PAUSE");
}
int reverse(char *a)
{
   if(*a!='\0')
   {   
     reverse(a+1);
   }
   printf("%c",*a);
}         
Run Code Online (Sandbox Code Playgroud)

它打印反转的字符串,但我想要反转的字符串main().我怎样才能做到这一点?

c string recursion

2
推荐指数
2
解决办法
2万
查看次数

标签 统计

c ×1

recursion ×1

string ×1