VC 2010学习版怎么能设置执行完不退出DOS窗口

2025-11-03 01:04:25

1、新建VC工程,新建HelloWorld.cpp

写入

#include<iostream>

using namespace std;

int main()

{

cout << "hello world" << endl;

}

这时候执行后DOS窗口会闪退

2、把代码改成

#include<iostream>

using namespace std;

int main()

{

cout << "hello world" << endl;

getchar();

}

这是需要你输入字符,窗口才会消失。这就是getchar()函数

3、可以考虑用较高版本的VS,DOS窗口也不会消失的

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢