Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 02 / task2.cpp
diff options
context:
space:
mode:
1 files changed, 38 insertions, 0 deletions
-rw-r--r--Sem. 02/task2.cpp38
diff --git a/Sem. 02/task2.cpp b/Sem. 02/task2.cpp
new file mode 100644
index 0000000..4a0faa1
--- /dev/null
+++ b/Sem. 02/task2.cpp
@@ -0,0 +1,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!";
+ }
+
+}