std::fstream file("filename", std::fstream::in | std::fstream::out | std::fstream::trunc); if (file) { file << "Some text"