FILE – TEXT

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
// _______ ofstream (write)
// |
//fstream ——————|
// |______ ifstream (read)
//
main()
{
int no;
char name[10];
clrscr();
ofstream of;
of.open(“file2.txt”);
cout<<“Enter the no:”;
cin>>no;
of<<no<<endl;
cout<<“Enter the name:”;
cin>>name;
of<<name<<endl;
of.close();

ifstream fi;
fi.open(“file2.txt”);
fi>>no;
cout<<“No:”<<no<<endl;
fi>>name;
cout<<“name: “<<name;
fi.close();

getch();
}

Share

About the Author

Akash Padhiyar

Visit Website

There are no comments yet, add one below.

Leave a Comment

Your email address will not be published. Required fields are marked *

*

Time limit is exhausted. Please reload CAPTCHA.