gpt4 book ai didi

C 数组 : showing big numbers as the output when its index goes out of bound

转载 作者:太空宇宙 更新时间:2023-11-04 08:39:07 26 4
gpt4 key购买 nike

<分区>

我试图测试当我尝试打印索引超出范围的数组时我会得到什么输出。

代码:

#include <stdio.h>

void main()
{

int arr[] = { 3, 4, 5 };

for (int i = 0; i < 5; i++)
{
if (arr[i] == 0)
{
printf("Breaking out of the loop.");
break;

}

else
printf("%i\n", arr[i]);
}


getchar();
}

当我运行这段代码时,输​​出是:

3
4
5
-858993460
3997200

我希望它打印出“Breaking out of the loop”并跳出循环并终止。我真的不知道它是如何打印这些数字的。

知道这些数字是什么意思吗?

附言如果这是一个愚蠢的问题,我很抱歉,我对 C 还很陌生。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com