Professional Documents
Culture Documents
h>
#include<conio.h>
#include<string.h>
#include<iomanip.h>
#include<process.h>
#include<stdio.h>
#include<ctype.h>
class student
{
char name[20];
char add[20];
char place[10];
char fname[25];
char mname[25];
char school[25];
char contact[20];
int age;
int d,m,y;
int srno;
int standard;
float studentno;
public:
void getdata();
void showdata();
int getsno();
}s;
int student::getsno()
{
return studentno;
}
void student::getdata()
{
clrscr();
cout<<"\n\tEnter the Student no.:\t\t";
cin>>studentno;
cout<<"\tEnter the Name of the Student :\t";
gets(name);
cout<<"\tEnter Date/Month/Year of Birth :\t";
cin>>d>>m>>y;
cout<<"\tEnter the Place of Residence :\t";
gets(place);
cout<<"\tEnter Name of Student's Father :\t";
gets(fname);
cout<<"\tEnter Name of Student's Mother :\t";
gets(mname);
textcolor(BLACK);
clrscr();
fstream fin;
fin.open("project.dat",ios::in|ios::binary);
if(fin==NULL)
{
cout<<"error";
exit(0);
}
fin.read((char*)&s,sizeof(s));
cout<<"Studentno"<<setw(10)<<"Name"<<setw(12)<<"D.O.B"<<setw(12)<<"Place";
cout<<setw(18)<<"Father's Name"<<setw(18)<<"Mother's Name";
while(!fin.eof())
{
s.showdata();
fin.read((char*)&s,sizeof(s));
}
fin.close();
getch();
}
void modify()
{
textbackground(YELLOW);
textcolor(BLACK);
clrscr();
fstream f;
int ch,rec=0,sno;
f.open("project.dat",ios::in|ios::out|ios::binary);
if(f==NULL)
{
cout<<"file opening error";
exit(0);
}
cout<<"\nENTER THE STUDENT NO WHICH IS TO BE MODIFIED";
cin>>ch;
f.read((char*)&s,sizeof(s));
while(!f.eof())
{
if(ch==s.getsno())
{
f.seekp(rec*sizeof(s),ios::beg);
s.getdata();
f.write((char*)&s,sizeof(s));
break;
}
else
{
f.read((char*)&s,sizeof(s));
rec++;
}
}
f.close();
}
void del()
{
textbackground(WHITE);
textcolor(BLUE);
clrscr();
fstream fin,fout;
student s;
int sno;
fin.open("project.dat",ios::in|ios::binary);
if(fin==NULL)
{
cout<<"file opening error";
return;
}
fout.open("temp.dat",ios::out|ios::binary);
cout<<"enter student no whose information you want to delete\n";
cin>>sno;
fin.read((char*)&s,sizeof(s));
while(!fin.eof())
{
if(sno!=s.getsno())
{
fout.write((char*)&s,sizeof(s));
}
fin.read((char*)&s, sizeof(s));
}
fin.close();
fout.close();
fin.open("temp.dat",ios::in|ios::binary);
fout.open("project.dat",ios::out|ios::binary);
fin.read((char*)&s,sizeof(s));
while(!fin.eof())
{
fout.write((char*)&s,sizeof(s));
fin.read((char*)&s,sizeof(s));
}
fin.close();
fout.close();
}
void credits()
{
textbackground(BLACK);
textcolor(GREEN);
clrscr();
cout<<"\n\n\t\tThis is Program on ::STUDENT MANAGEMENT SYSTEM::\n";
cout<<"
\n";
cout<<setw(20)<<"==>SUBMITTED TO"<<setw(45)<<"==>PREPARED BY\n";
cout<<"
\n";
cout<<setw(25)<<"#Mr Harendar Daila";
cout<<setw(43)<<"#Simarpal Singh\n";
cout<<setw(68)<<"#Ankur Tripathi\n";
cout<<setw(67)<<"#Tejveer Singh\n";
getch();
}
void writefile();
void modify();
void view();
void credits();
void main()
{
textmode(C80);
clrscr();
student s;
int c;
do
{
textbackground(RED);
textcolor(YELLOW);
clrscr();
cout<<"\n\n\t\t* * * * STUDENT MANAGEMENT SYSTEM * * * *\n";
cout<<"\t\t\* \t\t\t\t\t*\n";
cout<<"\t\t\* Press 1 to Enter the Record\t\t\*\n";
cout<<"\t\t\* \t\t\t\t\t\*\n";
cout<<"\t\t\* Press 2 to View the Record \t\t\*\n";
cout<<"\t\t\* \t\t\t\t\t\*\n";
cout<<"\t\t\* Press 3 to Modify the Record\t\t\*\n";
cout<<"\t\t\* \t\t\t\t\t\*\n";
cout<<"\t\t\* Press 4 to Delete the Record\t\t\*\n";
cout<<"\t\t\* \t\t\t\t\t\*\n";
cout<<"\t\t\* Press 5 for Credit\t\t\t\*\n";
cout<<"\t\t\*
\t\t\t\t\*\n";
cout<<"\t\t\* Press 6 to Exit\t\t\t\*\n";
cout<<"\t\t\*
\t\t\t\t\*\n";
cout<<"\t\t* * * * * * * * * * * * * * * * * * * * *\n";
cout<<"
\n";
cout<<"\n\n\t\tEnter the Choice\t\t\n";
cin>>c;
switch(c)
{
case 1:
writefile();
break;
case 2:
view();
getch();
break;
case 3:
modify();
break;
case 4:
del();
break;
case 5:
credits();
break;
case 6:
exit(0);
default:
clrscr();
cout<<"\n\n\t\tWRONG CHOICE !! PLEASE PRESS 1 TO 5 \n\n\n"<<endl;
cout<<"\t **********************************************\n\n";
getch();
cout<<"\n\n\n\n\t\t\t\tTHANKYOU !!! ";
getch();
}
}
while(1);
}