1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 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; }