教你用VS2008/VS2010写简单C/C++语言main函数程序
来源:互联网 发布:qq飞车指挥官改装数据 编辑:程序博客网 时间:2024/06/05 10:08
1.首先打开VS2008/VS2010,选择创建工程。
2.Project种类下面选择Visual C++/Win32/Win32 Console application.
3.接下来的向导中你可以选择ATL / MFC,根据需要选择。
这样就创建了一个带有main函数的文件,如果你程序要输出到终端的话,你根本看不到。因为main的函数返回值返回后程序就结束了,mian函数的返回值0表示正常结束,返回0意外的值都代表一种错误。
如果你要看到命令行输出内容的话,有以下三种方法:
①加上一句系统暂停命令system("pause");即可
②或者你在return 0;语句前前设个断点),
③或者在程序无错的情况下直接按Ctrl+F5(开始执行(不调试))。
// Console application(Start from the main funtion).cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include "stdafx.h"
#include "Console application(Start from the main funtion).h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 唯一のアプリケーション オブジェクトです。
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// MFC を初期化して、エラーの場合は結果を印刷します。
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: 必要に応じてエラー コードを変更してください。
_tprintf(_T("致命的なエラー: MFC の初期化ができませんでした。\n"));
nRetCode = 1;
}
else
{
// TODO: アプリケーションの動作を記述するコードをここに挿入してください。
cout<<"Start from here"<<endl;
// Add your codes here.
cout<<"End to here"<<endl;
// The program will stop at here,so that you can see the output message on the black window.
system("pause");
}
return nRetCode;
}
- 教你用VS2008/VS2010写简单C/C++语言main函数程序
- 怎么用VS2010写C语言程序
- 用VS2010写C语言程序
- 怎么用VS2010写C语言程序
- C语言程序可以没有main函数
- C语言程序可以没有main函数
- C语言main函数
- C语言main函数
- c语言main函数
- C语言main函数
- 使用vs2008写c程序
- C语言写的简单病毒程序
- 【c/c++】C语言main()函数详解
- C语言简单写日志函数
- VS2008编译C语言程序
- 【诡异的精简C语言程序】main函数隐藏
- 【诡异的精简C语言程序】main函数隐藏
- c语言程序总是从main函数开始执行吗?
- APMServ启用.htaccess伪静态重写功能,APMServ设置伪静态
- android:layout_weight属性的使用
- Request.返回值
- POJ 3126 Prime Path BFS
- sql developer无法更新数据
- 教你用VS2008/VS2010写简单C/C++语言main函数程序
- C# 中的委托和事件
- 回文字符串的测试
- windows下安装emacs收藏
- 如果分配给命令的连接位于本地挂起事务中,ExecuteNonQuery 要求命令拥有事务。命令的 Transaction 属性尚未初始化
- C#獲取指定文件夾的所有檔案
- 对话框大全
- jstl标签库
- 雷声大雨点小!!!