Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
874 B
5
Indexable
Never
#include<iostream>
#include<fstream>

using namespace std;

class student{
public:
int roll;
char name[10];
int marks;

void data();
void display();
};
void student::data(){
cout<< "Enter the student details"<<endl;
cout<<"Enter name:"<<endl;
	cin>>name;
	cout<<"Enter roll:"<<endl;
	cin>>roll;
	cout<<"Enter marks:"<<endl;
	cin>>marks;
}

void student :: display(){
cout <<name<<endl;
cout << roll<<endl;
cout << marks<<endl;
}
int main(){

student s[10];
fstream file;
file.open("plane.txt",ios::out);
if (!file){
	cerr<<"File not found."<<endl;
}

for (int i=10;i<10;i++){
s[i].data();

//file.write(&s[i],sizeof(s[i]);
file<<s[i].name<<s[i].roll<<s[i].marks;
}

file.close();

file.open("plane.txt",ios::in);

for (int i=0;i<10;i++){
if( s[i].marks>s[i+1].marks){
file>>s[i].name;
}
}

file.close();

return 0;
}