#include<iostream>
#include<stdio.h>
using namespace std;
void student_array();
void query();
void show_arr();
void student_entry();
struct student
{
char name[80];
char f_name[80];
char the_class[3];
char grade[2];
};
student std_arr[10];
char action;
int count;
int main()
{
cout<<"add 1st student"<<endl;
student_entry();
}
void student_entry()
{
if (count == 10)
{
cout<<"Memory Full!";
//break;
}
cout<<"enter name of student"<<endl;
cin>>std_arr[count].name;
//cout<<std_arr[count].name;
cout<<"enter student's father's name"<<endl;
cin>>std_arr[count].f_name;
cout<<"enter the class of student"<<endl;
cin>>std_arr[count].the_class;
cout<<"enter the grade of student"<<endl;
cin>>std_arr[count].grade;
query();
count++;
}
void query()
{
cout<<"what do you want to do?"<<endl;
cout<<"press a to add"<<endl;
cout<<"press s to show"<<endl;
cout<<"press q to quit"<<endl;
cin>>action;
//cout<<action;
switch (action)
{
case 'a':
{
student_entry();
break;
}
case 's':
{
show_arr();
break;
}
default:
{
cout<<"wrong entry";
query();
break;
}
}
}
void show_arr()
{
for (int i = 0; i < count; i++)
{
cout<<endl<<"Student No."<<count<<endl;
cout<<"Name: "<<std_arr[i].name<<endl;
cout<<"Father's Name: "<<std_arr[i].f_name<<endl;
cout<<"Class: "<<std_arr[i].the_class<<endl;
cout<<"Grade Achieved: "<<std_arr[i].grade<<endl;
}
}
My switch structure is not calling the show_arr() function on the case of s.