how to create search student list enrolled for a given course in menu bar

this is my UMS. through this system stores the entire folder of the student. this system have add data, serch data, delete data, update data function. i want to add course name function for add student function then can save data and user when enter course name can find the enrolled student list.




// University Management System.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <vector>
#include <windows.h>
#include <conio.h>
using namespace std;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);

void addStudent(string studentid,string fname, string surname,string address,string contactno,int age);
void displayAllStudents();
void updateFirstName(string studentid);
void updateSurName(string studentid);
void updateAddress(string studentid);
void updateContactNo(string studentid);
void updateAge(string studentid);
void searchStudent(string studentid);
void deleteStudent(string studentid);
void SubMenu();
void menu();
void setcolor(int value);




void setcolor(int value)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), value);


}


void menu()
{


cout<< " " <<endl;
cout<< " " <<endl;
HANDLE color=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(color,10);
cout<<" ** University ";
SetConsoleTextAttribute(color,11);
cout<<"Management";
SetConsoleTextAttribute(color,14);
cout<<" System **"<<endl;
//=====================================================================
setcolor(15);
cout<<" "<<endl;
cout<< " 1 : Register Student" <<endl;
cout<< " 2 : Display all Students" <<endl;
cout<< " 3 : Update Student" <<endl;
cout<< " 4 : Search Student" <<endl;
cout<< " 5 : Delete Student" <<endl;
setcolor(13);
cout<< " 6 : Help" <<endl;
cout<< " 7 : About Software" <<endl;
setcolor(12);
cout<< " 8 : Exit" <<endl;

cout<< " " <<endl;
setcolor(11);

cout<< " * Enter the number * " <<endl;
setcolor(15);
int input;
cout<< " "; cin>> input; //get the user input for function number
cout<<endl;

if (input==1)
{

string studentid;
string fname;
string surname;
string address;
string contactno;
int age;

setcolor(15);
cout<<"Enter Student ID"<<endl;
cin>>studentid;

cout<<"Enter First Name"<<endl;
cin>>fname;

cout<<"Enter Surname"<<endl;
cin>>surname;

cout<<"Enter Address"<<endl;
cin>>address;

cout<<"Enter Contact No"<<endl;
cin>>contactno;

cout<<"Enter Age"<<endl;
cin>>age;

addStudent(studentid,fname,surname,address,contactno,age);
}
else if (input==2){

displayAllStudents();
}

else if (input == 3){ //if value is == 3 execute scope and call the function
SubMenu();


}
else if (input==4){

string studentid;
cout<<"Enter Student Id"<<endl;
cin>>studentid;
searchStudent(studentid);

}
else if(input==5){
string studentid;
cout<<"Enter Student Id"<<endl;
cin>>studentid;
deleteStudent(studentid);
}
else if (input==6)

{
setcolor(13);
cout<<" Into Main Menu "<<endl;
setcolor(14);
cout<<" Press 1 : Can be Add student details"<<endl;
cout<<" Press 2 : Can be display all student detals"<<endl;
cout<<" Press 3 : Can be Update Student Details"<<endl;
cout<<" Press 4 : Can be Search student details"<<endl;
cout<<" Press 5 : Can be Delete student details"<<endl;
cout<<" Press 6 : Can be Get Some Help"<<endl;
cout<<" Press 7 : About this Software"<<endl;
cout<<" Press 8 : Exit"<<endl;
setcolor(15);
cout<<" "<<endl;
setcolor(13);
cout<<" Into Update Menu "<<endl;
cout<<" "<<endl;
setcolor(14);
cout<<" press 1 : Can be update First Name "<<endl;
cout<<" press 2 : Can be update Sur Name "<<endl;
cout<<" press 3 : Can be update Address "<<endl;
cout<<" press 4 : Can be update Contact No "<<endl;
cout<<" press 5 : Can be update Age "<<endl;
cout<<" press 6 : Back to Main Menu "<<endl;
setcolor(15);
}
else if (input==7)
{

cout<<" This is the university management system which will be used to register student in university. "<<endl;
cout<<" All details will be saved to a Folder as and when users need student details can be recall by the same folder."<<endl;
cout<<" Also if needed any student detail can be updated as well as all student details can be deleted and search. "<<endl;
cout<<" "<<endl;
cout<<" Mniversity Management System "<<endl;
cout<<" Version 5.7.1 "<<endl;
cout<<" "<<endl;
cout<<" 2017 Esoft Metro Campus"<<endl;
cout<<" HND Batch 14"<<endl;
cout<<" Malindu Darshana "<<endl;
cout<<" "<<endl;
cout<<" All rights reserved"<<endl;
}
else if (input==8)
{
exit(EXIT_FAILURE);
}


else {
setcolor(12);
cout << " Invalid number";
setcolor(15);
cout << " ";
cout << " ";

}



}


void SubMenu()
{
cout<< " " <<endl;
cout<< " 1 : Update First Name" <<endl;
cout<< " 2 : Update Sur Name" <<endl;
cout<< " 3 : Update Address" <<endl;
cout<< " 4 : Update Contact no" <<endl;
cout<< " 5 : Update Age" <<endl;
setcolor(13);
cout<< " 6 : Menu Back" <<endl;
cout<< endl;
setcolor(11);

cout<< " * Enter the number * " <<endl;
setcolor(15);

int input;
cout<< " "; cin>> input; //get the user input for function number
if (input==1)
{
string studentid;
cout<<"Enter Student Id"<<endl;
cin>>studentid;
updateFirstName(studentid);
SubMenu();
}
else if(input==2)
{
string studentid;
cout<<"Enter Student Id"<<endl;
cin>>studentid;
updateSurName(studentid);
SubMenu();
}
else if(input==3)
{
string studentid;
cout<<"Enter Student Id"<<endl;
cin>>studentid;
updateAddress(studentid);
SubMenu();
}
else if(input==4)
{
string studentid;
cout<<"Enter Student Id"<<endl;
cin>>studentid;
updateContactNo(studentid);
SubMenu();
}
else if (input==5)
{
string studentid;
cout<<"Enter Student Id"<<endl;
cin>>studentid;
updateAge(studentid);
SubMenu();

}
else if (input==6)
{
menu();
}
else
{
setcolor(12);
cout << " Invalid number";
setcolor(15);
cout << " ";
cout << " ";
}


}


void addStudent(string studentid,string fname, string surname,string address,string contactno,int age)
{


ofstream infile;
infile.open ("D:/UMS/"+studentid+".txt");
infile <<setw(10)<<left<<studentid<<'\n';
infile <<setw(10)<<left<<fname<<'\n';
infile <<setw(10)<<left<<surname<<'\n';
infile <<setw(10)<<left<<address<<'\n';
infile <<setw(10)<<left<<contactno<<'\n';
infile <<setw(10)<<left<<age<<'\n';

infile.close();
string sage=age+"";

string newstr=studentid+'\n'+fname+'\n'+surname+'\n'+address+'\n'+contactno+'\n'+sage+'\n';
ofstream infileall;
infileall.open ("D:/UMS/allStudents.txt",ios::app);
infileall<<newstr;
infileall.close();
setcolor(10);
cout<<" Operation successfully executed"<<endl;

setcolor(15);


}

int_tmain(int argc, _TCHAR* argv[])
{
string r;
int hold;
menu();

cout<<" ";
cout << " Do you want to continue ? (Y/N/) :";

cin >> r;

while (r=="Y"||r=="y")
{
menu();

cout<<" ";
cout << " Do you want to continue ? (Y/N/) :";

cin >> r;
}
//=============================================================



//==========================================================

if ((r=="N"||r=="n"))
{
exit(EXIT_FAILURE);

}

cin>>hold;
return 0;
}
Topic archived. No new replies allowed.