Question
#include #include #include #include using namespace std; const int SIZE=5; struct Student{ string name; string age; string score; string grade; string remark; }; int readFile(Student
#include
using namespace std; const int SIZE=5;
struct Student{
string name;
string age;
string score;
string grade;
string remark;
}; int readFile(Student sList[]){
fstream ifile;
ifile.open("data.txt",ios::in);
if (!ifile){
cout
return 0;
} cout
int i=0;
string temp1, temp2;
while (!ifile.eof()){
getline(ifile,sList[i].name); getline(ifile,sList[i].age); getline(ifile,sList[i].score); i++; }
} void dispAll(Student sList[], int nos){
for (int i=0; i cout cout cout char selection; cout cout cin>>selection; return selection; } void addStud(Student sl[],int &nos){ int i; cout>sl[i].name; cout>sl[i].age; cout>sl[i].score; nos++; makeSelection(); } int main() { Student studList[SIZE]; char selection; int numOfStud=0; do { selection = makeSelection(); system("CLS"); switch(selection){ case 'a':{ cout numOfStud= readFile (studList); break; } case 'c':{ cout addStud(studList, numOfStud); break; } case 'd':{ cout dispAll(studList, numOfStud); break; } default:{ cout break; } case 'x':{ cout break; } } cout } while (selection !='x'); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started