Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 02 / task2.cpp
blob: 4a0faa1fc2124ce36c0805ecf225a067e4e7b3c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <fstream>
using namespace std;


bool copyFile(const char* source, const char* dest)
{
	ifstream inputFile(source);
	ofstream outputFile(dest, ios::app);

	if (!inputFile.is_open() || !outputFile.is_open())
		return false;

	while (!inputFile.eof())
	{
		char line[1024];
		inputFile.getline(line, 1024);
		outputFile << line << std::endl;
	}
	inputFile.close();
	outputFile.close();
	return true;
}



int main()
{
	if (copyFile("Source.cpp", "AnotherSource.cpp"))
	{
		std::cout << "Succesfully copied!";
	}
	else
	{
		std::cout << "Error while copying!";
	}

}