我如何使用输入参数作为对文件的传递?

问题描述 投票:0回答:1

我是C ++的新手,我当前要解决的任务是将一个目录中* .txt文件中的某些数据解析到另一目录中的* + 1.txt文件中。我使用了代码示例:

#include <iostream>
#include <fstream>  
#include <string>
#include <stdio.h>

int main(int argc, char*argv[]){
std::ifstream input("C:\\Tmp\\example.txt");
std::string outfilepass = "";
    outfilepass +=argv[2];
    outfilepass +="\\";
    outfilepass += argv[1];
std::ofstream outfile(outfilepass);
return 0;
}

如果我编译然后使用sample.exe example1.txt“ C:\ Tmp \ NewFolder \”在Windows 10中一切正常,但在Windows 7中什么也没有发生。

!更新

我已经找到了一些有用的链接,这些链接可以帮助我找到解决方案。问题出在该应用程序的目标平台中。 (我用过VS 2019)。以下是一些有用的链接:

Visual Studio 2015 Change target platform to windows 7

https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?redirectedfrom=MSDN&view=vs-2019

我是C ++的新手,我当前要解决的任务是将一个目录中* .txt文件中的某些数据解析到另一目录中的* + 1.txt文件中。我使用了代码示例:#include&...

c++
1个回答
0
投票

我已经找到了一些有用的链接,这些链接可以帮助我找到解决方案。问题出在该应用程序的目标平台中。 (我用过VS 2019)。以下是一些有用的链接:

© www.soinside.com 2019 - 2024. All rights reserved.