-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
struct student{ | ||
int admno; | ||
char name[30]; | ||
char add[80]; | ||
float fees; | ||
}; | ||
|
||
int main(){ | ||
|
||
ifstream fin("student.dat"); | ||
ofstream fout("temp.dat"); | ||
|
||
student s; | ||
int tadmno; | ||
|
||
cout<<"\n Enter Admno no that you want to delete "; | ||
cin>>tadmno; | ||
|
||
while(fin.read((char *)&s,sizeof(student))){ | ||
if(s.admno!=tadmno){ | ||
fout.write((char *)&s,sizeof(student)); | ||
} | ||
} | ||
fin.close(); | ||
fout.close(); | ||
|
||
remove("student.dat"); | ||
rename("temp.dat","student.dat"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
ifstream fin("sarthak.txt"); | ||
ofstream fout("dup.txt"); | ||
char ch; | ||
while(fin.get(ch)){ | ||
fout<<ch; | ||
} | ||
fin.close(); | ||
fout.close(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
struct student{ | ||
int admno; | ||
char name[30]; | ||
char add[80]; | ||
float fees; | ||
}; | ||
|
||
int main(){ | ||
|
||
ifstream fin("student.dat"); | ||
student s; | ||
cout<<"\n Data from file \n"; | ||
|
||
while(fin.read((char *)&s,sizeof(student))){ | ||
cout<<"\n Admno :"<<s.admno; | ||
cout<<"\n Name :"<<s.name; | ||
cout<<"\n Address :"<<s.add; | ||
cout<<"\n Fees :"<<s.fees; | ||
} | ||
fin.close(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
struct student{ | ||
int admno; | ||
char name[30]; | ||
char add[80]; | ||
float fees; | ||
}; | ||
|
||
int main(){ | ||
ofstream fout("student.dat",ios::app); | ||
student s; | ||
char choice; | ||
do{ | ||
cout<<"\n Enter admno :"; | ||
cin>>s.admno; | ||
cout<<"\n Enter name : "; | ||
cin>>s.name; | ||
cout<<"\n Enter address :"; | ||
cin>>s.add; | ||
cout<<"\n Enter fees : "; | ||
cin>>s.fees; | ||
fout.write((char *)&s, sizeof(student)); | ||
cout<<"\n Want to add more records(y/n) :"; | ||
cin>>choice; | ||
}while(choice!='n'); | ||
|
||
fout.close(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
struct student{ | ||
int admno; | ||
char name[30]; | ||
char add[80]; | ||
float fees; | ||
}; | ||
|
||
int main(){ | ||
|
||
ifstream fin("student.dat"); | ||
ofstream fout("temp.dat"); | ||
|
||
student s; | ||
int tadmno; | ||
|
||
cout<<"\n Enter Admno no that you want to update "; | ||
cin>>tadmno; | ||
|
||
while(fin.read((char *)&s,sizeof(student))){ | ||
if(s.admno==tadmno){ | ||
cout<<"\n Enter new address :"; | ||
cin>>s.add; | ||
cout<<"\n Enter new fees :"; | ||
cin>>s.fees; | ||
} | ||
fout.write((char *)&s,sizeof(student)); | ||
} | ||
fin.close(); | ||
fout.close(); | ||
|
||
remove("student.dat"); | ||
rename("temp.dat","student.dat"); | ||
|
||
return 0; | ||
} |