为什么此递归程序即使分配后仍具有垃圾值

问题描述 投票:-1回答:2

the values in image appear from no where 这些值是什么,如果嘿是垃圾值,那么为什么在分配J后这些值仍然存在我也附上了源代码,请尽快回复asap source

c gcc compiler-errors compiler-construction garbage
2个回答
0
投票

在函数ifsum块中,您在声明int f时未为其分配值,因此它具有垃圾值。唯一给它分配值的时间是在语句printf("f up is %d\n",f);之后。因此,此语句总是要打印垃圾值。


0
投票

如果使用未初始化的变量,将导致未定义的行为。并且您使用了未初始化的int f功能中if-else陈述中的sum。初始化它。

也不要使用void main使用int main

© www.soinside.com 2019 - 2024. All rights reserved.