方法一:
在你的控制台程序前加入
#ifdef _MSC_VER
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
#endif
在你的控制台程序前加入
#ifdef _MSC_VER
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
#endif
如下:
#ifdef _MSC_VER
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
#endif
#include <iostream>
using namespace std;
int main()
{
FILE *f=fopen("data.txt","w");
fputs("ssss",f);
cout<<"Hello world!"<<endl;
return 0;
}
方法二:
建立Win32工程,自己改成WinMain接口
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
cout<<"Hello world!"<<endl;
::MessageBox(NULL , "" , "" , 0);
//暂停程序,就可以在任务管理器看这个我们的程序是运行了!
return 0;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
main();
return 0;
}
原文:http://www.cnblogs.com/syxchina/archive/2010/12/14/2197274.html