Friday, 16 January 2015

File Structures - Cpp program to create a new file and write some data into it.

This is a C Program which creates a new file and writes some data into it.

We will use a filestream classes to create a new file in write mode then we enter some data into it.

Then we read  that data until end of file is reached and place that data in the  file we just created.

#include <iostream>
#include <fstream>

using namespace std;

int main()
    char data[100];
    ofstream outfile;"sample.txt");
    cout << "Write some text here !\n";
    outfile << data << endl;
    return 0;


No comments:

Post a Comment