#include
<iostream.h>
#include
<fstream.h>
#include
<stdlib.h>
Int main()
{ system(“cls”);
Ofstream fout(“student”,ios::out); //connect student file to output
stream fout
char name[30],ch;
float markes=0.0;
//loop to get 5 records
for(int I=0;i<5;i++)
{ cout<<”Student”<<(i+1)<<”:\tName:”;
cinget(name(30);
cout<<”\t\tMarks:”;
cin>>marks; cin.get(ch); //to empty input bugger
fout<<name<<’\n’<<marks<<”\n”;
}
fout.close(); //disconnect
student file from fout
ifstream fin(“student”,ios::in); //connect studentfile with
input stream fin
fin.seekg(0); //to
bring the file pointer at the file begaining
cout<<”\n”;
for(i=0li<5;i++) //display
record
{ fin.get(name,30); //read
name from student
fin.get(ch);
fin>>marks;; //read
marks from file student
fin.get(ch);
cout<<”Student
Name:”<<name;
cout<<”\tMarks:”<<marks<<”\n”;
}
fin.close(); //disconnect
student file from the stream
return 0;
}
No comments:
Post a Comment