如何使用输入参数作为文件的传递?
How can I use input parameter as a pass to the file?
我是 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;
}
如果我编译它然后使用 示例.exe示例 1.txt"C:\Tmp\NewFolder\" 在 Windows 10 中一切正常,但在 Windows 7 中没有任何反应。
!更新
我找到了一些有用的链接,帮助我找到了解决方案。问题出在应用程序的目标平台上。(我用过VS 2019(。以下是一些有用的链接:
Visual Studio 2015 将目标平台更改为 Windows 7
https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?redirectedfrom=MSDN&view=vs-2019
我找到了一些有用的链接,帮助我找到了解决方案。问题出在应用程序的目标平台上。(我用过VS 2019(。以下是一些有用的链接:
Visual Studio 2015 将目标平台更改为 Windows 7
https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?redirectedfrom=MSDN&view=vs-2019
该解决方案是在发布版本中构建的
#define WINVER 0x0601 и _WIN32_WINNT 0x0601
相关文章:
- 有充分的理由在h文件中使用include保护而不是cpp文件吗
- 如何在其他文件中使用函数
- 在实现文件中使用头文件的通用 lambda
- 将 getline() 与文件一起使用
- 在头文件和 cpp 文件中使用一次 #pragma 时出现结构重定义错误
- 定义C++新的环境变量并在 bat 文件中使用它
- 如何在另一个 CPP 文件中使用一个 cpp 文件中的函数?
- 在 embarcadero / RAD 工作室中的 .dfm 文件中使用常量
- 声明要在 qml 和 cpp 文件中使用的全局字符串
- 如何在 linux 可执行文件中使用静态库
- 在C++的头文件中使用常量并在程序中询问其地址的任何潜在危险
- 使用 libssh 从 SFTP 服务器下载文件并使用 C++ 将其写入 ofstream?
- CocoaPod - 在头文件中使用 C++ 时出现 Podspec 检查错误
- 链接器输入文件未使用,因为链接未完成,我无法获得.o
- 使用个人C++库编译代码时,与头文件一起使用时会中断
- 如何为文件路径使用变量?
- 没有头文件如何使用c ++调用其他模块中的函数?
- 在带有类型保护的模板文件中使用前向声明
- 无法使包含.hpp文件与其中的2个文件一起使用
- 文件删除(使用取消链接)与释放所有磁盘空间之间的延迟