gpt4 book ai didi

C++ : Read a file name from the command line and utilize it in my file

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:25:06 27 4
gpt4 key购买 nike

如何从命令行读取文件名并在我的 C++ 代码文件中使用它?

例如:./cppfile inputFilename outputFilename

非常感谢任何帮助!

最佳答案

int main(int argc, char** argv) {
string inFile = "";
string outFile = "";
if( argc == 3 ) {
inFile = argv[1];
outFile = argv[2];
}
else {
cout << "Usage: ./cppfile InputFile OutputFile\n";
return 1;
}
...
}

关于C++ : Read a file name from the command line and utilize it in my file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7651243/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com