Program details: Program will display menu which will have 4 options
- New Enrollment of student
- editing students detail
- Updating details
- Show list of all students
If enrollment exceeds 45 it should give a message. There should be use of structures and functions. separate function for enrollment, edit and update so goes on. I have question from the code I have written. I am having confusion on how to use structure with function. I donot know if I am right or wrong. How to use pointers in this situation??
My updated code but still giving weird output, How to use functions with pointer when we are storing multiple data like in this code Data data[45].
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;
struct Date{
int day;
int month;
int year;
};
struct Data{
int id;
char firstName[20];
char lastName[20];
float PrimaryMarks;
float secondaryMarks;
Date date;
};
void enrollment(Data *dtai){
static int i=0;
if(i<45){
dtai->id=i+1;
cout<<"Enter the student's First Name"<<endl;
cin>>dtai->firstName;
cout<<"Enter the student's Last Name"<<endl;
cin>>dtai->lastName;
cout<<"Enter the student's Primary School Percentage"<<endl;
cin>>dtai->PrimaryMarks;
cout<<"Enter the student's Secondary School Percentage"<<endl;
cin>>dtai->secondaryMarks;
cout<<"Enter the day of enrollment"<<endl;
cin>>dtai->date.day;
cout<<"Enter the month of enrollment"<<endl;
cin>>dtai->date.month;
cout<<"Enter the year of enrollment"<<endl;
cin>>dtai->date.year;
}
i++;
}
int main(){
//taking students information menu display
Data data[45];
//int i=0;
int option;
char sentinal;
do{
int x=0;
//display menu
cout<<"Press 1 for New Enrollment"<<endl;
cout<<"Press 2 for editing student's detail"<<endl;
cout<<"Press 3 for updating student's detail"<<endl;
cout<<"Press 4 to see list of students"<<endl;
cin>>option;
switch(option){
case 1:
enrollment(&data[x]);
break;
case 2:
case 4:
}
cout<<"Press m to go to the menu again ";
cin>>sentinal;
}while(sentinal=='m');
return 0;
}
- Please tell me how to use structures with functions for multiple data.
I have just written my code for 1st option enrollment rest are remaining, Please answer my above question Thanks in advance