Windows控制台在运行C ++代码后立即关闭 [英] Windows console closing immediately after running a c++ code

查看:85
本文介绍了Windows控制台在运行C ++代码后立即关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Visual Studio在Windows 10上编写C ++代码,并且正在使用控制台应用程序模板.我的问题是,即使我只是运行"hello world"示例,控制台在显示程序输出后也会立即消失.我尝试了各种技巧来实现延迟,但没有成功.

I just started using Visual Studio to write C++ code on Windows 10 and I am using the console application template. My problem is that the console disappears immediately after showing the output of my program even when I simply run a "hello world" example. I tried all kinds of tricks to implement delay but no success.

推荐答案

我通常在主返回之前放置std :: cin行.这将导致它在继续输入之前等待输入.

I usually put a std::cin line just before main returns. This will cause it to wait for input before continuing.

这篇关于Windows控制台在运行C ++代码后立即关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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