c++ stream string into fiel

include

include

include

int main() { std::string text = "Hello, this is a sample text to be written to a file."; std::ofstream file("output.txt");

if (file.is_open()) {
    file << text;
    file.close();
} else {
    std::cout << "Unable to open file.";
}

return 0;

}