vs下c++中main _tmain以及控制台程序结束后不出现press any key to continue问题
来源:互联网 发布:qq音乐三巨头知乎 编辑:程序博客网 时间:2024/05/18 10:24
视频教程在VC6中编译运行。我的电脑装VC6有问题,所以安装了vs2003。结果发现很多问题。
新建完后出来这么一段:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
在下边写main()提示不能重载。
问百度,收藏下给用得着的人:
用过C的人都知道每一个C的程序都会有一个main(),但有时看别人写的程序发现主函数不是int main(),而是int _tmain(),而且头文件也不是<iostream.h>而是<stdafx.h>,会困惑吧?一起来看看他们有什么关系吧首先,这个_tmain()是为了支持unicode所使用的main一个别名而已,既然是别名,应该有宏定义过的,在哪里定义的呢?就在那个让你困惑的<stdafx.h>里,有这么两行.
#include <stdio.h>#include <tchar.h>我们可以在头文件<tchar.h>里找到_tmain的宏定义 #define _tmain main所以,经过预编译以后, _tmain就变成main了,这下明白了吧!
这通过后,可是问题又来了,编译成功后出现命令提示符后,一闪面过,不显示press any key to continue
再找百度,这样就可以了:
#include "stdafx.h"#include"stdlib.h"int _tmd(){std::cout<<"这是我的第一个C++程序\n";int x;std::cin>>x;std::cout<<x;system("pause");return 0;}
或者
#include "stdafx.h"#include"conio.h"int _tmain(){std::cout<<"这是我的第一个C++程序\n";int x;std::cin>>x;std::cout<<x;getch();return 0;}2种解决方案。
自己备份下,省得将来忘记了。
链接:http://blog.csdn.net/qq_25572699/article/details/43118999
阅读全文
0 0
- vs下c++中main _tmain以及控制台程序结束后不出现press any key to continue问题
- vs下c++中main _tmain以及控制台程序结束后不出现press any key to continue问题
- 如何让VS.net中的控制台程序出现Press any key to continue字样?
- VC_VC2010打开调试单个CPP文件的COUT时候不会出现press any key to continue
- vs2010运行没有“press any key to continue...”
- 虚拟机开机时出现Press ESC in 5 seconds to skip startup.nsh, any other key to continue问题的解决办法
- Press any key to continue 原来是 这么写出来的
- VS中VC控制台程序结束后暂停
- Load Error!Press any key to reboot
- press any key to out demo
- 使用Homebrew管理你的mac开发包( Press RETURN to continue or any other key to abort)
- 系统出现“NTLDR is missing press any key to restart”问题解决方案
- 电脑出现"NTLDR is Missing Press any key to restart "如何解决.
- 开机时出现NTLDR is missing Press any key to restart 解决方法
- Rufus安装Win7操作系统出现“press any key to boot from usb”解决方案
- line 1 of the inf file winnt.xpe is invalid setup cannot continue. press any key to exit
- 【程序32】Press any key to change color(TC实现版本)
- vs中 main和_tmain的区别
- SAP中凭证类型的作用
- UTF-8编码原理
- Android 使用NDK开发中,遇到memset,memcpy, malloc函数错误
- POJ 1921 Paper Cut 笔记
- opencv实现多个图拼接成一个图
- vs下c++中main _tmain以及控制台程序结束后不出现press any key to continue问题
- HTML学习笔记-列表标签
- App logo图标或内部icon的动态替换
- Hibernate HQL
- Centos6.5 LAMP环境源码包安装与配置,附安装包百度网盘地址
- 一个自定义时间选择器
- 安卓四大组件-Activity
- Tomcat server.xml详解
- SpringAOP环绕通知的使用