void main()改为
int main()
void 无返回
写 teturn;
int 写return X;(X为int类型,不需要一定要为0)
返回值取决于确切的平台,可能是程序集级别返回寄存器(例如 x86 上的 EAX)中发生的任何随机值。
C function defined as int but having no return statement in the body still compiles
Technically, if a non-void function returns without a value and the function’s return value is used, the behavior is undefined (C99 §6.9.1/12) – it might return a random value, it could crash, etc. On x86, it will probably just use whatever junk is in the EAX register. But on other architectures, such as IA64, uninitialized garbage could be deadly. – Adam Rosenfield
从技术上讲,如果非空函数返回没有值并且使用了函数的返回值,则行为未定义(C99 §6.9.1/12)——它可能返回一个随机值,它可能会崩溃等。在 x86 上 ,它可能只会使用 EAX 寄存器中的任何垃圾。 但是在其他架构上,例如 IA64,未初始化的垃圾可能是致命的。 — 亚当·罗森菲尔德
首先需要看一下具体的错误提示是什么,然后再根据错误提示来进行修改。一般来说,选择结构中的return语句是没有问题的,可能是其他地方的代码出了问题导致了这个错误。建议先仔细检查代码,看看是否有语法错误、变量未定义等问题,如果还是不行,可以把具体的错误提示和代码放在问题中,这样大家才能更好地帮助你解决问题。