Website Summary Files Commits Branches @commit @diff @stats
path: root / Week06 / Exercise03.cpp
diff options
context:
space:
mode:
1 files changed, 22 insertions, 0 deletions
-rw-r--r--Week06/Exercise03.cpp22
diff --git a/Week06/Exercise03.cpp b/Week06/Exercise03.cpp
new file mode 100644
index 0000000..5b26705
--- /dev/null
+++ b/Week06/Exercise03.cpp
@@ -0,0 +1,22 @@
+#include <iostream>
+#include <fstream>
+
+int main() {
+ // Във файловите системи, имената на файлове са с ограничена дължина,
+ // така че и ние да работим с ограничена дължина е коректно
+ char fileName[1024];
+ std::cin.getline(fileName, sizeof(fileName) / sizeof(*fileName));
+
+ std::ofstream outFile(fileName);
+
+ if (!outFile.is_open()) {
+ std::cout << "Couldn't open file!" << std::endl;
+ }
+ else {
+ for (char curr = std::cin.get(); curr != '@'; curr = std::cin.get()) {
+ outFile.put(curr);
+ }
+ }
+
+ return 0;
+}