#include<iostream.h> #include<conio.h> #include<fstream.h> #include<stdio.h> #include<stdlib.h> class student { int sno; char name[25],stream[10]; public: void get() { cout<<"\nEnter Student Number : "; cin>>sno; cout<<"\nEnter Student Name : "; gets(name); cout<<"\nEnter Student's Stream : "; gets(stream); } void show() { cout<<"\nStudent Number : "<<sno; cout<<"\nStudent Name : "<<name; cout<<"\nStudent's Stream : "<<stream; } }; void main() { fstream file("stud.txt",ios::in|ios::out|ios::ate); student s; int c; while(1) { cout<<"\n\nPress 1 - to enter student detail\nPress 2 - to view all student detail\nPress 4 - to exit :\n"; cin>>c; if(c==1) { s.get(); file.write((char*)&s,sizeof(s)); } else if(c==2) { file.seekg(ios::beg); while(!(file.eof())) { file.read((char*)&s,sizeof(s)); s.show(); } } else if(c==4) { exit(0); } else { cout<<"\nINVALID OPTION !!\n choose correct option from menu......"; } } }
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
To store student detail in file and to display the same :-
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment