【C++练习】文件合并程序

代码:

#include 
#include 
#include 
#include 
#include 

int main(int argc,char* argv[])
{
	std::string Name1st, Name2nd;
	if (3 != argc)
	{
		std::cout << "Input the first file name : \n";
		std::cin >> Name1st;
		std::cout << "Input the second file name : \n";
		std::cin >> Name2nd;
	}
	else
	{
		Name1st = argv[1];
		Name2nd = argv[2];
	}
	
	std::ofstream fout;
	std::ifstream fin1st, fin2nd;
	
	fin1st.open(Name1st.c_str(), std::ios_base::in | std::ios_base::binary);
	
	if (fin1st.is_open())
		std::cout << "Successfully open " << Name1st << std::endl;
	else
	{
		std::cerr << "Error in opening " << Name1st << std::endl;
		std::cin.get();
		std::cin.get();
		std::exit(EXIT_FAILURE);
	}

	fin2nd.open(Name2nd.c_str(), std::ios_base::in | std::ios_base::binary);

	if (fin2nd.is_open())
		std::cout << "Successfully open " << Name2nd << std:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值