我用c++写了一个基本的代码
#include <iostream>
using namespace std;
void main()
{
cout <<"its my programm";
}
当我编译它时,cmd 行出现一秒钟,并显示终止注释。它在调试窗口中向我展示了这个输出。
'while.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'while.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'while.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcp90d.dll'
'while.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcr90d.dll'
The program '[1480] while.exe: Native' has exited with code 0 (0x0).
帮我解决这个问题。
最佳答案
#include <iostream>
using namespace std
int main() {
cout << "Hello World";
cin.get();
return 0;
}
这应该有效。在您可以查看程序之前控制台退出。使用 cin.get() 将使程序保持运行,直到您按下 enter。
与此相关,您的 main() 函数确实应该是 int 而不是 void。我很确定有些编译器不允许 void main()。
关于Visual Studio 2008 Express Edition 中的 C++ 第一个程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10663104/