我开始在Visual c++和我想知道如何保持控制台窗口。
例如,这将是一个典型的“hello world”应用程序:
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Hello World";
return 0;
}
我漏了哪一行?
我开始在Visual c++和我想知道如何保持控制台窗口。
例如,这将是一个典型的“hello world”应用程序:
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Hello World";
return 0;
}
我漏了哪一行?
当前回答
sin .get()或system("PAUSE")。 我没听说过你可以用return(0);
其他回答
我的观点:
选择1:在main()的末尾添加断点
选择2:在返回0之前添加这段代码:
std::cout << "Press ENTER to continue..."; //So the User knows what to do
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
对于std::numeric_limits,您需要包含<iomanip>
我也有同样的问题。我在return语句之前使用了_getch()。它的工作原理。
另一种选择是使用
#include <process.h>
system("pause");
虽然这不是很可移植,因为它只能在Windows上工作,但它会自动打印
按任意键继续…
sin .get()或system("PAUSE")。 我没听说过你可以用return(0);
在返回行上放置断点。
你在调试器中运行它,对吧?