// 22_22-4.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <fstream>
#include <string>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	ifstream fin;
	ofstream fout;
	string ss;

	if (argc != 3) {
		cout << "入力誤り: cp_cpy4 fromfile tofile\n";
		MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);
		return 1;
	}

	fin.open(argv[1]);
	if (!fin) {
		cout << argv[1] << "をオープンできません\n";
		MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);
		return 1;
	}

	fout.open(argv[2]);
	if (!fout) {
		cout << argv[2] << "をオープンできません\n";
		MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);
		return 1;
	}

	while (getline(fin, ss)) {
		fout << ss << '\n';
	}

	fin.close();
	fout.close();

	MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);

	return 0;
}

