SlideShare a Scribd company logo
ONLINE STUDENT
MANAGEMENT SYSTEM
SUBJECT: ADVANCE DATA STRUCTURES
SUBMITTED TO: MR. MAGETO VICTOR SIR
SUBMITTED BY: PURSHOTTAM VERMA
SID: 57920 (B.tech CSE Vth Sem.)
OVERVIEW
Databases are being used in every aspect of our lives right now. Trillions of bytes of
data are being stored in servers around the world. SQL is one of the most basic
methods to use such a database. But have you ever thought about using C++ to
maintain such a database. In this post, we will talk about implementing different views
on a text file according to the type of user and edit accordingly.
The data stored using this code are:
1) Registration number
2) Name
3) Marks in CSE1001
4) Marks in CSE1002
5) Proctor ID
SOURCE CODE
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;
int main(){
//Considering the max length of data entered (name) to be 15.
char data[15];
int n = 0, option = 0, count_n = 0;
//This is the initial mark alloted to a subject.
string empty = "00";
string proctor = "";
//Name of the file in which DB is stored.
ifstream f("Example.txt");
string line;
//The following for loop counts the total number of lines in the file.
for (int i = 0; std::getline(f, line); ++i){
count_n++;}
while(option != 6){
//This prints out all the available options in the DB
cout << "nAvailable operations: n1. Add New Studentsn2."
<< "Student Loginn3. Faculty Loginn4. Proctor Loginn5. Admin Viewn"
<< "6. ExitnEnter option: ";
cin >> option;
if(option == 1){
cout << "Enter the number of students: ";
cin >> n;
count_n = count_n + n;
for (int i = 0;i < n;i++){
ofstream outfile;
outfile.open("Example.txt",ios::app);
//The entire data of a single student is stored line-by-line.
cout << "Enter your registration number: ";
cin >> data;
outfile << data << "t";
cout << "Enter your name: ";
cin >> data;
int len = strlen(data);
while (len < 15){
data[len] = ' ';
len = len + 1;
}
outfile << data << "t";
//Inserting empty data initially into the file
outfile << empty << "t";
outfile << empty << "t";
cout << "Enter your proctor ID: ";
cin >> proctor;
outfile << proctor << endl;
}}
else if (option == 2){
char regno[9];
cout << "Enter your registration number: ";
cin >> regno;
ifstream infile;
int check = 0;
infile.open("Example.txt",ios::in);
//This loop prints out the data according to the registration number specified.
while (infile >> data){
if (strcmp(data,regno) == 0){
cout << "nRegistration Number: " << data << endl;
infile >> data;
cout << "Name: " << data << endl;
infile >> data;
cout << "CSE1001 mark: " << data << endl;
infile>>data;
cout<<"CSE1002 mark: "<<data<<endl;
infile>>data;
cout<<"Proctor ID: "<<data<<endl;
infile.close();
check = 1;}
}
if (check == 0){
cout<<"No such registration number found!"<<endl;}
}
//This loop is used to view and add marks to the database of a student.
else if (option == 3){
char subcode[7];
cout << "Enter your subject code: ";
cin >> subcode;
string code1 = "CSE1001", code2 = "CSE1002",mark = "";
ifstream infile;
int check = 0;
cout << "nAvailable operations: n1. Add data about marksn"
<< "2. View datanEnter option: ";
cin >> option;
if (option == 1){
cout << "Warning! You would need to add mark"
<< "details for all the students!" << endl;
for(int i = 0;i < count_n;i++){
fstream file("Example.txt");
//The seek in file has been done according to the length
//of the data being inserted. It needs to adjusted accordingly
//for diffferent lengths of data.
if(strcmp(subcode,code1.c_str()) == 0){
file.seekp(26+37*i,std::ios_base::beg);
cout << "Enter the mark of student#" << (i+1) << " : ";
cin >> mark;
file.write(mark.c_str(),2);}
if(strcmp(subcode,code2.c_str()) == 0){
file.seekp(29+37*i,std::ios_base::beg);
cout << "Enter the mark of student#" << (i+1) << " : ";
cin >> mark;
file.write(mark.c_str(),2);}
}
}
//This loop is used to view marks of a student.
//The extra infile commands have been used to get a specific mark
//only since the data has been seperated by a tabspace.
else if(option == 2){
infile.open("Example.txt",ios::in);
if (strcmp(subcode,code1.c_str()) == 0){
cout << "Registration number - Marksn" << endl;
while(infile >> data){
cout << data;
infile >> data;
infile >> data;
cout << " - " << data << endl;
infile >> data;
infile >> data;
check = 1;
}
}
infile.close();
infile.open("Example.txt",ios::in);
if(strcmp(subcode,code2.c_str()) == 0){
cout << "Registration number - Marksn" << endl;
while(infile >> data){
cout << data;
infile >> data;
infile >> data;
infile >> data;
cout << " - " << data << endl;
infile >> data;
check = 1;
}
}}
infile.close();
if (check == 0){
cout << "No such subject code found!" << endl;
}
}
//This loop displays all the details of students under the same proctor ID.
else if (option == 4){
char procid[7];
cout << "Enter your proctor ID: ";
cin >> procid;
int check = 1;
char temp1[100], temp2[100], temp3[100];
char temp4[100], id[100];
ifstream infile;
infile.open("Example.txt",ios::in);
while (infile >> temp1){
infile >> temp2;
infile >> temp3;
infile >> temp4;
infile >> id;
if (strcmp(id,procid) == 0){
cout << "nRegistration Number: " << temp1 << endl;
cout << "Name: " << temp2 << endl;
cout << "CSE1001 Mark: " << temp3 << endl;
cout << "CSE1002 Mark: " << temp4 << endl;
check = 1;
}
}
if (check == 0){
cout << "No such proctor ID found!" << endl;
}}
//This loop acts as an admin view to see all the data in the file.
else if(option == 5){
char password[25];
cout << "Enter the admin password: ";
cin >> password;
//This variable value can be changed according to your requirement
//of the administrator password.
string admin_pass = "admin";
if (strcmp(password,admin_pass.c_str()) == 0){
cout << "Reg No. tNametCSE1001tCSE1002tProctor ID" << endl;
ifstream infile;
infile.open("Example.txt",ios::in);
char data[20];
while(infile >> data){
cout << data << "t";
infile >> data;
cout << data << "t";
infile >> data;
cout << data << "t";
infile >> data;
cout << data << "t";
infile >> data;
cout << data << endl;
}
}
}
}}
THANK YOU

More Related Content

What's hot

Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
Jeff Tu Pechito
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
gkgaur1987
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
Rajeev Sharan
 

What's hot (20)

C programs
C programsC programs
C programs
 
C++ file
C++ fileC++ file
C++ file
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 
JVM code reading -- C2
JVM code reading -- C2JVM code reading -- C2
JVM code reading -- C2
 
P5
P5P5
P5
 
Opp compile
Opp compileOpp compile
Opp compile
 
JavaScript Proxy (ES6)
JavaScript Proxy (ES6)JavaScript Proxy (ES6)
JavaScript Proxy (ES6)
 
C program
C programC program
C program
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
Ccc
CccCcc
Ccc
 
RAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAMRAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAM
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
DConf 2016 std.database (a proposed interface & implementation)
DConf 2016 std.database (a proposed interface & implementation)DConf 2016 std.database (a proposed interface & implementation)
DConf 2016 std.database (a proposed interface & implementation)
 
[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis
[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis
[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
Institute management
Institute managementInstitute management
Institute management
 

Similar to ONLINE STUDENT MANAGEMENT SYSTEM

Sample file processing
Sample file processingSample file processing
Sample file processing
Issay Meii
 
file handling final3333.pptx
file handling final3333.pptxfile handling final3333.pptx
file handling final3333.pptx
radhushri
 
Chpater29 operation-on-file
Chpater29 operation-on-fileChpater29 operation-on-file
Chpater29 operation-on-file
Deepak Singh
 
PCI Security Requirements - secure coding
PCI Security Requirements - secure codingPCI Security Requirements - secure coding
PCI Security Requirements - secure coding
Haitham Raik
 

Similar to ONLINE STUDENT MANAGEMENT SYSTEM (20)

File Handling in C++ full ppt slide presentation.ppt
File Handling in C++ full ppt slide presentation.pptFile Handling in C++ full ppt slide presentation.ppt
File Handling in C++ full ppt slide presentation.ppt
 
Sample file processing
Sample file processingSample file processing
Sample file processing
 
Exmaples of file handling
Exmaples of file handlingExmaples of file handling
Exmaples of file handling
 
file handling final3333.pptx
file handling final3333.pptxfile handling final3333.pptx
file handling final3333.pptx
 
File Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswerFile Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswer
 
Chpater29 operation-on-file
Chpater29 operation-on-fileChpater29 operation-on-file
Chpater29 operation-on-file
 
CGI.ppt
CGI.pptCGI.ppt
CGI.ppt
 
A miało być tak... bez wycieków
A miało być tak... bez wyciekówA miało być tak... bez wycieków
A miało być tak... bez wycieków
 
CSNB244 Lab5
CSNB244 Lab5CSNB244 Lab5
CSNB244 Lab5
 
Nitin Mishra 0301EC201039 Internship PPT.pptx
Nitin Mishra 0301EC201039 Internship PPT.pptxNitin Mishra 0301EC201039 Internship PPT.pptx
Nitin Mishra 0301EC201039 Internship PPT.pptx
 
Sense And Simplicity Info Path Task Forms Made Easy
Sense And Simplicity   Info Path Task Forms Made EasySense And Simplicity   Info Path Task Forms Made Easy
Sense And Simplicity Info Path Task Forms Made Easy
 
Object Oriented Programming using C++: Ch12 Streams and Files.pptx
Object Oriented Programming using C++: Ch12 Streams and Files.pptxObject Oriented Programming using C++: Ch12 Streams and Files.pptx
Object Oriented Programming using C++: Ch12 Streams and Files.pptx
 
Object Oriented Programming Using C++: Ch12 Streams and Files.pptx
Object Oriented Programming Using C++: Ch12 Streams and Files.pptxObject Oriented Programming Using C++: Ch12 Streams and Files.pptx
Object Oriented Programming Using C++: Ch12 Streams and Files.pptx
 
Railway reservation
Railway reservationRailway reservation
Railway reservation
 
PCI Security Requirements - secure coding
PCI Security Requirements - secure codingPCI Security Requirements - secure coding
PCI Security Requirements - secure coding
 
Gaurav Jatav , BCA Third Year
Gaurav Jatav , BCA Third YearGaurav Jatav , BCA Third Year
Gaurav Jatav , BCA Third Year
 
Secure erasure code based cloud storage system with secure data forwarding
Secure erasure code based cloud storage system with secure data forwardingSecure erasure code based cloud storage system with secure data forwarding
Secure erasure code based cloud storage system with secure data forwarding
 
Hack an ASP .NET website? Hard, but possible!
Hack an ASP .NET website? Hard, but possible! Hack an ASP .NET website? Hard, but possible!
Hack an ASP .NET website? Hard, but possible!
 
Taint scope
Taint scopeTaint scope
Taint scope
 
Hospital management
Hospital managementHospital management
Hospital management
 

More from Rohit malav

More from Rohit malav (20)

Aca lab project (rohit malav)
Aca lab project (rohit malav) Aca lab project (rohit malav)
Aca lab project (rohit malav)
 
operating system calls input and output by (rohit malav)
operating system calls input and output by (rohit malav)operating system calls input and output by (rohit malav)
operating system calls input and output by (rohit malav)
 
Python pandas liberary
Python pandas liberaryPython pandas liberary
Python pandas liberary
 
Presentation by purshotam verma
Presentation by purshotam vermaPresentation by purshotam verma
Presentation by purshotam verma
 
Deep learning in python by purshottam verma
Deep learning in python by purshottam vermaDeep learning in python by purshottam verma
Deep learning in python by purshottam verma
 
Atm Security System Using Steganography Nss ptt by (rohit malav)
Atm Security System Using  Steganography Nss ptt by (rohit malav)Atm Security System Using  Steganography Nss ptt by (rohit malav)
Atm Security System Using Steganography Nss ptt by (rohit malav)
 
Samba server Pts report pdf by Rohit malav
Samba server Pts report pdf by Rohit malavSamba server Pts report pdf by Rohit malav
Samba server Pts report pdf by Rohit malav
 
System calls operating system ppt by rohit malav
System calls operating system  ppt by rohit malavSystem calls operating system  ppt by rohit malav
System calls operating system ppt by rohit malav
 
A project on spring framework by rohit malav
A project on spring framework by rohit malavA project on spring framework by rohit malav
A project on spring framework by rohit malav
 
android text encryption Network security lab by rohit malav
android text encryption Network security lab by rohit malavandroid text encryption Network security lab by rohit malav
android text encryption Network security lab by rohit malav
 
samba server setup Pts ppt (rohit malav)
samba server setup Pts ppt (rohit malav)samba server setup Pts ppt (rohit malav)
samba server setup Pts ppt (rohit malav)
 
Spring frame work by rohit malav(detailed)
Spring frame work by rohit malav(detailed)Spring frame work by rohit malav(detailed)
Spring frame work by rohit malav(detailed)
 
spring framework ppt by Rohit malav
spring framework ppt by Rohit malavspring framework ppt by Rohit malav
spring framework ppt by Rohit malav
 
Samba server linux (SMB) BY ROHIT MALAV
Samba server linux (SMB) BY ROHIT MALAVSamba server linux (SMB) BY ROHIT MALAV
Samba server linux (SMB) BY ROHIT MALAV
 
Payroll system ppt1 (rohit malav)
Payroll system ppt1 (rohit malav)Payroll system ppt1 (rohit malav)
Payroll system ppt1 (rohit malav)
 
Payroll system ppt2 (rohit malav) version point 2
Payroll system ppt2 (rohit malav) version point 2Payroll system ppt2 (rohit malav) version point 2
Payroll system ppt2 (rohit malav) version point 2
 
digital unlock power point slide
digital unlock power point slidedigital unlock power point slide
digital unlock power point slide
 
Rohit android lab projects in suresh gyan vihar
Rohit android lab projects in suresh gyan viharRohit android lab projects in suresh gyan vihar
Rohit android lab projects in suresh gyan vihar
 
Snake report ROHIT MALAV
Snake report ROHIT MALAVSnake report ROHIT MALAV
Snake report ROHIT MALAV
 
Gyan vihar app
Gyan vihar appGyan vihar app
Gyan vihar app
 

Recently uploaded

RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
Atif Razi
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
Kamal Acharya
 

Recently uploaded (20)

weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker project
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Introduction to Casting Processes in Manufacturing
Introduction to Casting Processes in ManufacturingIntroduction to Casting Processes in Manufacturing
Introduction to Casting Processes in Manufacturing
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Construction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxConstruction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptx
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Toll tax management system project report..pdf
Toll tax management system project report..pdfToll tax management system project report..pdf
Toll tax management system project report..pdf
 

ONLINE STUDENT MANAGEMENT SYSTEM

  • 1. ONLINE STUDENT MANAGEMENT SYSTEM SUBJECT: ADVANCE DATA STRUCTURES SUBMITTED TO: MR. MAGETO VICTOR SIR SUBMITTED BY: PURSHOTTAM VERMA SID: 57920 (B.tech CSE Vth Sem.)
  • 2. OVERVIEW Databases are being used in every aspect of our lives right now. Trillions of bytes of data are being stored in servers around the world. SQL is one of the most basic methods to use such a database. But have you ever thought about using C++ to maintain such a database. In this post, we will talk about implementing different views on a text file according to the type of user and edit accordingly. The data stored using this code are: 1) Registration number 2) Name 3) Marks in CSE1001 4) Marks in CSE1002 5) Proctor ID
  • 3. SOURCE CODE #include<stdio.h> #include<iostream> #include<fstream> #include<string.h> using namespace std; int main(){ //Considering the max length of data entered (name) to be 15. char data[15]; int n = 0, option = 0, count_n = 0; //This is the initial mark alloted to a subject. string empty = "00"; string proctor = ""; //Name of the file in which DB is stored. ifstream f("Example.txt"); string line;
  • 4. //The following for loop counts the total number of lines in the file. for (int i = 0; std::getline(f, line); ++i){ count_n++;} while(option != 6){ //This prints out all the available options in the DB cout << "nAvailable operations: n1. Add New Studentsn2." << "Student Loginn3. Faculty Loginn4. Proctor Loginn5. Admin Viewn" << "6. ExitnEnter option: "; cin >> option; if(option == 1){ cout << "Enter the number of students: "; cin >> n; count_n = count_n + n; for (int i = 0;i < n;i++){ ofstream outfile; outfile.open("Example.txt",ios::app);
  • 5. //The entire data of a single student is stored line-by-line. cout << "Enter your registration number: "; cin >> data; outfile << data << "t"; cout << "Enter your name: "; cin >> data; int len = strlen(data); while (len < 15){ data[len] = ' '; len = len + 1; } outfile << data << "t"; //Inserting empty data initially into the file outfile << empty << "t"; outfile << empty << "t"; cout << "Enter your proctor ID: "; cin >> proctor; outfile << proctor << endl; }}
  • 6. else if (option == 2){ char regno[9]; cout << "Enter your registration number: "; cin >> regno; ifstream infile; int check = 0; infile.open("Example.txt",ios::in); //This loop prints out the data according to the registration number specified. while (infile >> data){ if (strcmp(data,regno) == 0){ cout << "nRegistration Number: " << data << endl; infile >> data; cout << "Name: " << data << endl; infile >> data; cout << "CSE1001 mark: " << data << endl; infile>>data; cout<<"CSE1002 mark: "<<data<<endl;
  • 7. infile>>data; cout<<"Proctor ID: "<<data<<endl; infile.close(); check = 1;} } if (check == 0){ cout<<"No such registration number found!"<<endl;} } //This loop is used to view and add marks to the database of a student. else if (option == 3){ char subcode[7]; cout << "Enter your subject code: "; cin >> subcode; string code1 = "CSE1001", code2 = "CSE1002",mark = ""; ifstream infile; int check = 0;
  • 8. cout << "nAvailable operations: n1. Add data about marksn" << "2. View datanEnter option: "; cin >> option; if (option == 1){ cout << "Warning! You would need to add mark" << "details for all the students!" << endl; for(int i = 0;i < count_n;i++){ fstream file("Example.txt"); //The seek in file has been done according to the length //of the data being inserted. It needs to adjusted accordingly //for diffferent lengths of data. if(strcmp(subcode,code1.c_str()) == 0){ file.seekp(26+37*i,std::ios_base::beg); cout << "Enter the mark of student#" << (i+1) << " : "; cin >> mark; file.write(mark.c_str(),2);}
  • 9. if(strcmp(subcode,code2.c_str()) == 0){ file.seekp(29+37*i,std::ios_base::beg); cout << "Enter the mark of student#" << (i+1) << " : "; cin >> mark; file.write(mark.c_str(),2);} } } //This loop is used to view marks of a student. //The extra infile commands have been used to get a specific mark //only since the data has been seperated by a tabspace. else if(option == 2){ infile.open("Example.txt",ios::in); if (strcmp(subcode,code1.c_str()) == 0){ cout << "Registration number - Marksn" << endl; while(infile >> data){ cout << data; infile >> data; infile >> data;
  • 10. cout << " - " << data << endl; infile >> data; infile >> data; check = 1; } } infile.close(); infile.open("Example.txt",ios::in); if(strcmp(subcode,code2.c_str()) == 0){ cout << "Registration number - Marksn" << endl; while(infile >> data){ cout << data; infile >> data; infile >> data; infile >> data; cout << " - " << data << endl;
  • 11. infile >> data; check = 1; } }} infile.close(); if (check == 0){ cout << "No such subject code found!" << endl; } } //This loop displays all the details of students under the same proctor ID. else if (option == 4){ char procid[7]; cout << "Enter your proctor ID: "; cin >> procid;
  • 12. int check = 1; char temp1[100], temp2[100], temp3[100]; char temp4[100], id[100]; ifstream infile; infile.open("Example.txt",ios::in); while (infile >> temp1){ infile >> temp2; infile >> temp3; infile >> temp4; infile >> id; if (strcmp(id,procid) == 0){ cout << "nRegistration Number: " << temp1 << endl; cout << "Name: " << temp2 << endl; cout << "CSE1001 Mark: " << temp3 << endl; cout << "CSE1002 Mark: " << temp4 << endl; check = 1; } }
  • 13. if (check == 0){ cout << "No such proctor ID found!" << endl; }} //This loop acts as an admin view to see all the data in the file. else if(option == 5){ char password[25]; cout << "Enter the admin password: "; cin >> password; //This variable value can be changed according to your requirement //of the administrator password. string admin_pass = "admin"; if (strcmp(password,admin_pass.c_str()) == 0){ cout << "Reg No. tNametCSE1001tCSE1002tProctor ID" << endl; ifstream infile;
  • 14. infile.open("Example.txt",ios::in); char data[20]; while(infile >> data){ cout << data << "t"; infile >> data; cout << data << "t"; infile >> data; cout << data << "t"; infile >> data; cout << data << "t"; infile >> data; cout << data << endl; } } } }}