Program to write in a text file

Home Forums C++ Program to write in a text file

This topic contains 0 replies, has 1 voice, and was last updated by  admin 4 months, 4 weeks ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #5242

    admin
    Keymaster

    //Program to write in a text file

    #include <iostream>
    using namespace std;

    int main()
    {
    ofstream fout;
    fout.open(“out.txt”);

    char str[300] = “Time is a great teacher”;

    //Write string to the file.
    fout << str;

    fout.close();
    return 0;
    }

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.