全部问题 > 当前问题

程序无法输出

--------------------Configuration: modi1 - Win32 Debug--------------------

Compiling...

program10.cpp

E:\C\3\program10.cpp(5) : error C2065: 'exit' : undeclared identifier

E:\C\3\program10.cpp(11) : warning C4508: 'main' : function should return a value; 'void' return type assumed

执行 cl.exe 时出错.


program10.obj - 1 error(s), 0 warning(s)


Cinderalla 2017-8-10 16:26:59

共 4 个回答

qqq 2017-8-10 17:30:18

把完整代码贴上来。

Cinderalla 2017-8-10 17:45:50

回复 qqq

#include <stdio.h>

void print()

{

printf("Hello World\n");

exit(0);

}

main()

{

print();

printf("end\n");

}


最佳答案

qqq 2017-8-11 09:53:03

#include <stdlib.h>

exit函数是包含在stdlib这个头文件里的,加上这一句就可以了。

Cinderalla 2017-8-11 10:13:15

回复 qqq:好的,非常感谢

问题来自: 主函数的几种形式