Home  >  Q&A  >  body text

java - 急等。vs写一个简单程序关闭黑窗老是响应很久,然后报错,无法再次运行

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


#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;
}
迷茫迷茫2743 days ago525

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-18 10:54:18

    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");.

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:54:18

    #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.

    reply
    0
  • Cancelreply