问题描述
关于c ++ ofstream的快速提问。在我的主要我把它声明为int main(int arg,char * argv [])。所以当我运行以下命令./program.cpp test.txt时,它将运行我的程序并将test.txt文件传递给它。我的问题是如何保存我的输出文件作为我传入的文件名。我知道使用ofstream但我不知道如何传入我传入我的程序测试的文件。我有以下代码。任何帮助都会很棒。谢谢
ofstream myfile("",ios :: out);
Quick question on c++ ofstream. in my main i have it declared as int main(int arg, char*argv[]). so that when i run the following command ./program.cpp test.txt it will run my program and pass the test.txt file into it. My question is how do i save my output file as the file name i passed in. i know to use ofstream but im not sure how to pass in the file i passed into my program to test. I have the following code.any help would be great. thanks
ofstream myfile(" ", ios::out);
推荐答案
这篇关于关于流的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!