gpt4 book ai didi

c - 为什么我得到以下输出 "**-858993460**"

转载 作者:行者123 更新时间:2023-11-30 20:54:37 24 4
gpt4 key购买 nike

为什么在使用以下代码时得到以下输出“-858993460”:

#include<stdio.h>

int aNumber(void);

int main()
{
printf("%d", aNumber());
return 0;
}

int aNumber(void) {
int x = 1;
}

我只是好奇。我知道我需要使用“return”来获取“printf”上的实际int 1

最佳答案

因为aNumber的返回值未定义。由于您不返回值,因此会发生未定义的行为。不要指望它。在许多机器上,EAX 存储返回值。如果您没有 EAX 值,则使用之前的值。

关于c - 为什么我得到以下输出 "**-858993460**",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38625778/

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