【发布时间】:2013-08-07 12:59:49
【问题描述】:
为了更快的输入,我读到您可以使用file-redirection 并包含一个已设置cin 输入的文件。
理论上应该像下面这样使用:
App.exe inputfile outputfile
据我从 C++ Primer 书中了解到,以下 C++ 代码 [1] 应该从文本文件中读取 cin 输入,并且不需要任何其他特殊指示,例如 [2]
[2]
include <fstream>
ofstream myfile;
myfile.open ();
[1] 以下 C++ 代码...
#include <iostream>
int main()
{
int val;
std::cin >> val; //this value should be read automatically for inputfile
std::cout << val;
return 0;
}
我错过了什么吗?
【问题讨论】:
-
是的——不应该这样使用。