c++ - 如何使用输入参数作为文件的传递?
问题描述
我是 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)。以下是一些有用的链接:
解决方案
我找到了一些有用的链接来帮助我找到解决方案。问题出在应用程序的目标平台上。(我用过 VS 2019)。以下是一些有用的链接:
Visual Studio 2015 将目标平台更改为 windows 7
该解决方案是内置的
#define WINVER 0x0601 и _WIN32_WINNT 0x0601
推荐阅读
- android - 运行 apk 文件时不显示图像实例,但在桌面上运行良好
- arrays - 使用数组和循环更新 MySQL 表
- python - 使用 python 使用 Outlook 365 发送敏感邮件
- excel - Excel - 在两个不同列中寻找两个不同值的重合并提取另一列
- css - 向 Angular Material 表中的列添加阴影
- google-apps-script - Google App Script - 日历更新触发器触发 4 次
- python-3.x - 修改字典列表中字典的键和值(python 3)
- javascript - 为什么我不能为 Firebase 的文档数据设置状态?
- reactjs - 如何在 React JS 中按对象将数组发布到服务器对象?
- node.js - 我如何通过 nodejs 通过 apollo-server 从服务器获取所有数据