如何保持控制台窗口在Visual C ++中打开? [英] How to keep the console window open in Visual C++?

查看:312
本文介绍了如何保持控制台窗口在Visual C ++中打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在Visual C ++,我想知道如何保持控制台窗口。

I'm starting out in Visual C++ and I'd like to know how to keep the console window.

例如,这将是一个典型的hello world application:

For instance this would be a typical "hello world" application:

int _tmain(int argc, _TCHAR* argv[])
{
    cout << "Hello World";
    return 0;
}

我缺少什么行?

推荐答案

使用 Ctrl + F5 而不只是 F5 启动项目。

Start the project with Ctrl+F5 instead of just F5.

控制台窗口现在将保持打开,按任意键继续。 。

The console window will now stay open with the Press any key to continue . . . message after the program exits.

请注意,这需要控制台(/ SUBSYSTEM:CONSOLE)链接器选项,您可以按如下所示启用:

Note that this requires the Console (/SUBSYSTEM:CONSOLE) linker option, which you can enable as follows:


  1. 打开项目,然后转到解决方案资源管理器。如果你在K& R中跟着我,你的解决方案将是hello,其下有1个项目,还有hello以粗体显示。


  2. 选择配置属性>链接器>系统配置 。

  3. 对于右侧窗格中的Subsystem属性,单击右侧列中的下拉框。

  4. 控制台(/ SUBSYSTEM:CONSOLE)

  5. 单击应用,等待其完成任何操作,然后单击确定(如果应用 ,请点击应用,然后返回并应用控制台选项)。

  1. Open up your project, and go to the Solution Explorer. If you're following along with me in K&R, your "Solution" will be 'hello' with 1 project under it, also 'hello' in bold.
  2. Right click on the 'hello" (or whatever your project name is.)
  3. Choose "Properties" from the context menu.
  4. Choose Configuration Properties>Linker>System.
  5. For the "Subsystem" property in the right-hand pane, click the drop-down box in the right hand column.
  6. Choose "Console (/SUBSYSTEM:CONSOLE)"
  7. Click Apply, wait for it to finish doing whatever it does, then click OK. (If "Apply" is grayed out, choose some other subsystem option, click Apply, then go back and apply the console option. My experience is that OK by itself won't work.)

CTRL -F5和子系统提示一起工作;它们不是单独的选项。

CTRL-F5 and the subsystem hints work together; they are not separate options.

(由DJMorreTX从 http://social.msdn.microsoft.com/Forums/en-US/vcprerelease/thread / 21073093-516c-49d2-81c7-d960f6dc2ac6

(Courtesy of DJMorreTX from http://social.msdn.microsoft.com/Forums/en-US/vcprerelease/thread/21073093-516c-49d2-81c7-d960f6dc2ac6)

这篇关于如何保持控制台窗口在Visual C ++中打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆