Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / Solutions Sem. 02 / exercise01.cpp
diff options
context:
space:
mode:
Commite3ae4cd3affc234e3127d5aa69c34f1c420b964d (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-03-05 15:54:29 +0200
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-03-05 15:54:29 +0200
Files2804784cedb61534f6fa34a7fc518f273db185d6 /Year 1/Object-oriented Programming/Solutions Sem. 02/exercise01.cpp
uni-projects-e3ae4cd3affc234e3127d5aa69c34f1c420b964d.tar
uni-projects-e3ae4cd3affc234e3127d5aa69c34f1c420b964d.tar.gz
uni-projects-e3ae4cd3affc234e3127d5aa69c34f1c420b964d.zip
Parent2d8b66aa122ad7c2c73a778160176e26a8de4ec0 (diff)
Added solutions from oop seminar 2
1 files changed, 22 insertions, 0 deletions
-rw-r--r--Year 1/Object-oriented Programming/Solutions Sem. 02/exercise01.cpp22
diff --git a/Year 1/Object-oriented Programming/Solutions Sem. 02/exercise01.cpp b/Year 1/Object-oriented Programming/Solutions Sem. 02/exercise01.cpp
new file mode 100644
index 0000000..a9517ca
--- /dev/null
+++ b/Year 1/Object-oriented Programming/Solutions Sem. 02/exercise01.cpp
@@ -0,0 +1,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();
+}