04_03.cpp

来自「一些C++的课件和实验源代码」· C++ 代码 · 共 40 行

CPP
40
字号
// 04_03.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <fstream>
using namespace std;

int main(int argc, char* argv[])
{
	ifstream in("srcfile.txt");
	ofstream out("destfile.txt");

	if(!in){
		cout << "cannot open file 'srcfile.txt'." << endl;
		return 0;
	}
	if(!out){
		cout << "cannot open file 'destfile.txt'." << endl;
		return 0;
	}

	char str[256];
	while(!in.eof()){
		in >> str;
		out << str;
	}
//	char ch;
//	while(in.get(ch))
//		out.put(ch);

	out.close();
	in.close();

	cout << "copy file finished! press any key to exit..." << endl;
	getch();
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?