java - 急等。vs写一个简单程序关闭黑窗老是响应很久,然后报错,无法再次运行
迷茫
迷茫 2017-04-18 10:52:18
0
2
519

后台进程里一直还关不了这个运行台程序,每次都要退出重进,怎么解决啊?


#include "stdafx.h"
#include "iostream"
#include <cstdlib>
using namespace std;


int main()
{
    int n = 1;
    cout << n;
    int nn= 3;
    cout << nn;
    int a[4];
    for (int i = 0;i < 4;i++)
    {
        a[i] = i;
    }
    for (int i = 0;i < 4;i++)
    {
        cout << a[i];
    }
    system("PAUSE");
    return 0;
}
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
黄舟

system("PAUSE"); Press any key to continue

However, once you do not enter any keys, then return 0; is not running and the process is not closed. This situation will occur if you compile with VS again.

After restarting the computer, try using the getch(); command to enter characters instead of system("PAUSE");.

刘奇
#include <iostream>
#include <cstdlib>

using namespace std;
int main()
{
    int n = 1;
    cout << n;
    int nn= 3;
    cout << nn;
    int a[4];
    for (int i = 0;i < 4;i++)
    {
        a[i] = i;
    }
    for (int i = 0;i < 4;i++)
    {
        cout << a[i];
    }
    return 0;
}

With slight modifications, everything works fine in the G++ environment.

Test the VS environment now.

Update:

Everything is normal in VS2015 environment.

Please provide more information.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!