Website Summary Files Commits Branches @commit @diff @stats
path: root / Week06 / Exercise01.cpp
diff options
context:
space:
mode:
1 files changed, 16 insertions, 0 deletions
-rw-r--r--Week06/Exercise01.cpp16
diff --git a/Week06/Exercise01.cpp b/Week06/Exercise01.cpp
new file mode 100644
index 0000000..ff6153f
--- /dev/null
+++ b/Week06/Exercise01.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+#include <fstream>
+
+int main() {
+ std::ofstream outFile("HelloWorld.txt", std::ios::trunc);
+
+ if (!outFile.is_open()) {
+ std::cout << "Couldn't open file!" << std::endl;
+ }
+ else {
+ const char HELLO_WORLD[] = "Hello World!";
+ outFile.write(HELLO_WORLD, sizeof(HELLO_WORLD) / sizeof(*HELLO_WORLD));
+ }
+
+ return 0;
+}