该程序不能在DOS模式下运行 [英] This program cannot be run in DOS mode
本文介绍了该程序不能在DOS模式下运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试一个程序,并使用GCC编译并运行它,但它引发错误,说明它无法在dos模式下运行。这里是我的代码
I was trying out a program and compiling and running it with GCC but it throws error that it cannot be run in dos mode. Here is my code
#include<iostream>
#include<fstream>
using namespace std;
int main(int argc, char *argv[])
{
ifstream is;
is.open("text1.txt",ios::binary);
ofstream outfile;
outfile.open("text2.txt",ios::binary);
char ch;
while (is.get(ch))
{
outfile.put(ch);
cout << ch; //this shows
}
is.close();
outfile.close();
getchar();
return 0;
}
但是这段代码在Visual Studio中工作得很好。任何建议?
But this code works perfectly fine in Visual Studio. Any suggestions?
推荐答案
我假设有一个 gcc
编译选项作为控制台命令运行。请参阅 -mconsole
此处: http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Windows-Options.html
I'm supposing there's a gcc
compile option for to run as a console command. See -mconsole
here: http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Windows-Options.html
这篇关于该程序不能在DOS模式下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文