#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
int main(int args, char **argv)
{
std::string infile, outfile;
std::cout << "请输入所要读取文件的文件名: ";
std::cin >> infile;
while( (fopen(infile.c_str(),"rb")) == NULL )
{
std::cout << "文件不存在!" << std::endl;
std::cout << "请重新输入所要读取文件的文件名: ";
std::cin >> infile;
}
std::cout << "请输入所要存取到的文件名: ";
std::cin >> outfile;
int copyNumber = 2;
std::cout << "请问需要复制多少遍? 请输入数字 : ";
std::cin >> copyNumber;
std:: cout << "start read```" << std::endl;
std::ifstream fin(infile.c_str(), std::ios::in);
std::ofstream fout(outfile.c_str(), std::ios::out
c++按行读取写入文件
最新推荐文章于 2024-07-22 00:07:08 发布
本文介绍如何使用C++编程语言按行读取文本文件,并将每行内容复制两遍写入到另一个文件中。
摘要由CSDN通过智能技术生成