Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / Solutions Sem. 02 / exercise01.cpp
blob: a9517caba5b01e55cd3fdbf43853aa223da58b18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream> // cin, cout
#include <fstream>  // ifstream

const int LINE_BUFFER_SIZE = 1024;

int main() {
	std::ifstream sourceFile("exercise01.cpp");

	if (!sourceFile.is_open()) {
		std::cout << "Error: Couldn't open file!" << std::endl;
		return -1;
	}

	char buffer[LINE_BUFFER_SIZE];
	while (!sourceFile.eof()) {
		sourceFile.getline(buffer, LINE_BUFFER_SIZE);
		std::cout << buffer;
		if (!sourceFile.eof()) std::cout << std::endl;
	}

	sourceFile.close();
}