小编use*_*653的帖子

分段错误错误:反转字符串时

#include<stdio.h>
#include<string.h>
void reverseMe(char *,int,int);
int main()
{
  char str[]="cycle";
  int len=strlen(str);
  reverseMe(str,0,len-1);
  return 0;
}

void reverseMe(char *x,int begin,int end)
{
  char c;
  c=*(x+begin);
  *(x+begin)=*(x+end);
  *(x+end)=c;

  reverseMe(x,++begin,--end);
}
Run Code Online (Sandbox Code Playgroud)

为什么会出现分段错误?我犯的错误是什么?

c segmentation-fault

-1
推荐指数
1
解决办法
34
查看次数

标签 统计

c ×1

segmentation-fault ×1