为了获得更快的输入,我看到您可以执行file-redirection,并包含一个已经设置了cin输入的文件。
从理论上讲,它的使用应如下所示:
App.exe inputfile outputfile据我从C++入门书中了解到,下面的C++ code1应该读取文本文件中的cin输入,而不需要任何其他特殊指示like2
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;
}我是不是遗漏了什么?
发布于 2013-08-06 13:28:25
要使用代码1,您必须像这样调用您的程序:
App.exe < inputfile > outputfile您还可以使用:
App.exe < inputfile >> outputfile在这种情况下,输出不会用命令的每次运行来重写,但是输出将被附加到已经存在的文件中。
有关在Windows中重定向输入和输出的更多信息,您可以找到这里。
请注意,<、>和>>符号将逐字输入--它们不只是用于本解释中的表示目的。因此,例如:
App.exe < file1 >> file2https://stackoverflow.com/questions/18081565
复制相似问题