反序输出字符串,出现发生访问冲突异常
#include <stdio.h>
#include <string.h>
int main()
{
char revert(char x[30]);
char a[30];
int c;
gets(a, 30);
revert(a);
printf("%s\n", a);
return 0;
}
char revert(char x[30])
{
int m,n;
m = strlen(x);
char y[30];
for (n = 0;n <= m;n++)
{
y[n] = x[m-1-n];
}
for (n = 0;n <= m;n++)
{
x[n] = y[n];
}
x[m + 1] = "\0";
return(x);
}
运行结果及报错内容
我想要达到的结果
怎么改