输出到windows cmd提示符
Output to windows cmd prompt
我被告知制作一个将输出5行的exe文件。我得到了这样的指示:
程序运行后不能挂起。我将在命令行执行它,并期望它在程序完成时结束。
我试着去属性->链接器->系统->控制台。当我按ctrl-f5键时,它似乎按他的意思做了。然后我做了一个exe,现在它消失了,它没有打印到控制台。
我正在使用一个简单的计数程序,例如:
int main()
{
cout<<"hello"<<endl;
return 1;
}
编辑我正在使用visual studio 2013,我从命令行运行。注意,我不是要求窗口保持打开状态,而是要求打印到控制台本身。我没有按ctrl-f5,而是转到cmd.exe,然后转到可执行文件。我已经尝试了发布版本和调试版本。
如果我理解了你的问题。尝试以下方法并将有用的部分添加到代码中。不需要的行被注释掉。
// ConsoleApplication1.cpp : Defines the entry point for the console application.
// (Just 2 ways to wait, befoore command-line console vanishes.)
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout << "It's Foo's Bar!n";
system("pause"); //preferred way.
//cin.get(); //2nd way, not as good.
return 0;
}
相关文章:
- 如何使用ndk-build.cmd构建Android.so文件
- 如何使 windows 命令提示符在C++可执行文件上显示返回值?
- 在由Sublime文本3编译后在cmd上显示Java程序输出
- 如何在使用Makefile构建后在cmd中运行该程序?
- C++命令行提示符不应重复
- 为什么下面的Hello World程序在PowerShell上没有显示任何输出?同一程序在CMD上显示正确的输出
- 如何使用命令提示符、记事本和 MinGW 使用主文件、头文件和实现文件编译C++程序?
- 父进程意外被子 cmd 杀死.exe运行 java jar 的进程 - WINDOWS 7 问题 - C++
- 使用 CreateProcessWithTokenW 在 CMD 中启动 CMD
- 使用 system() 函数在C++程序中运行 cmd 命令
- 终端如何在 shell 提示符下以编程方式阻止退格,以便您无法在其上退格,例如 $ 表示 bash 或 C:\blah\>
- cmd.exe与Powershell中C++程序的不同执行时间
- Windows 10命令提示符的输出不正确
- C++ - 如何将空格键转换为短划线以进行cmd输入
- 删除控制台/cmd提示符上闪烁的下划线
- 在VS cmd提示符下运行.bat文件
- 输出到windows cmd提示符
- OpenGL不显示正确的输出时,没有运行在cmd提示符
- 使我的cpp应用程序不打开cmd提示符,如果我点击exe
- 对system()的调用与在命令提示符(cmd)中的行为不同