#include<iostream.h> #include<conio.h> #include<fstream.h> #include<stdio.h> class student { int roll; char name[15]; public: void get() { cout<<"\n enter roll"; cin>>roll; cout<<"\n enter name"; gets(name); } void show() { cout<<"\nRoll :"<<roll<<endl; cout<<"\n Name :"<<name<<endl; } }; void main() { ofstream fout("stu.dat"); student s; int i; for(i=0;i<5;i++) { s.get(); fout.write((char*)&s,sizeof s); } fout.close(); ifstream fin("stu.dat"); clrscr(); cout<<"Details Entered into File are :\n"; cout<<"------------------------------------------------\n\n"; while(fin) { fin.read((char*)&s,sizeof s); s.show(); } getch(); }
It's an attempt to help all C.Sc. students (of Class 11 and 12). Search for your needs, for better search try labels (at right sidebar), and message your reviews and requests. Have a Pleasant Programming !! :)
Make Your Search Easy ! :) Use me
Friday, February 17, 2017
Writing in a data file :-
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment