HelloWorld应用程序执行两次

时间:2014-08-19 16:50:08

标签: managed-c++

我在学校开设了一个C ++课程,我的第一个任务当然是HelloWorld。我的代码如下:

#include "stdafx.h"
#include <iostream>

using namespace System;

int main(array<System::String ^> ^args)
{
    Console::WriteLine("Hello World");//print hello world
    system("PAUSE");//wait for button press
    return 0;
}

它按预期工作,除非我按任意键继续&#39;,提示再次出现。 Visual Studio中的最后一行输出如下所示:

The thread 'Win32 Thread' (0x1664) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x11f4) has exited with code 0 (0x0).
The program '[3032] HelloWorld.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
The program '[3032] HelloWorld.exe: Native' has exited with code 0 (0x0).

因此,它似乎在2个单独的线程中启动应用程序。为什么会这样?提前谢谢。

2 个答案:

答案 0 :(得分:1)

今天使用c#控制台应用程序遇到了同样的问题。每次我执行.exe文件时,窗口都会打开,一段时间后它会关闭并弹出一个新窗口。在做了一些研究后,我发现我必须禁用Avast Antivirus&#39; Deep Screen&#39;特征即可。它现在运行正常。

答案 1 :(得分:0)

我有同样的问题。

我用

解决了我的问题
#include "stdafx.h"
#include <stdio.h>
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{

    system("PAUSE");
    return 0;
}

而不是...返回0;在它之后,系统(“PAUSE”);

相关问题