Untitled

 avatar
unknown
plain_text
17 days ago
545 B
3
Indexable
#include<iostream>
#include<fstream>
using namespace std;

int main()
{
    ofstream ofile;
    ifstream ifile;
    char data[100];
    ofile << "Welcome in c++ . Regards: CSE Department, GITS"<< endl;
    cout << "\nData written to file"<< endl;
    ofile.close();

    //create a text file before executing.
    ifile.open ("text.txt");
    cout<<"\nData read from the file:";
    while (!ifile.eof())
    {
        ifile.getline (data,100);
        cout<<data<<endl;
        }
        ifile.close();
        return 0;
}
Leave a Comment