Spirit_ZeroHeart @ 2023-10-22 17:28:32
求助大佬,为什么这个是错的,测试了一下感觉没错
int main()
{
int i;
char c[4];
for(i=4;i>=0;i--)
{
scanf("%c",&c[i]);
}
printf("%s",c);
return 0;
}````
by xiaoshumiao @ 2023-10-22 17:39:40
char c[4];
你数组越界了,改成:
char c[5];
by xiaoshumiao @ 2023-10-22 17:40:35
不过还是有问题,我看看。
by xiaoshumiao @ 2023-10-22 17:43:09
哦,我知道了。char数组最后会加上一个'\0',所以需要改成:
char c[6];
by xiaoshumiao @ 2023-10-22 17:43:52
以后建议把数组开大一点。
by HMYH @ 2023-10-22 18:33:14
最后一行为什么有’’’‘
by Spirit_ZeroHeart @ 2023-10-25 15:00:29
@xiaoshumiao 哦哦!好的,谢谢大佬!