1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include <cstdio>
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
ifstream inStream;
struct student{
int id;
char fname[20];
char lname[20];
char email[40];
double gpa;
};
struct roster{
struct student;
};
// list all function prototypes here
int displayMenu(int recNum);
bool getRecord(int& recNum, int& id, char fname[20], char lname[20], char email[40], double& gpa);
void displayStudents();
int main(){
int recNum = 0, x = 0, id;
char fname, lname, email;
double gpa;
getRecord(recNum, id, &fname, &lname, &email, gpa);
while (x == 0){
displayMenu(recNum);
cout << ">> ";
int choice = 0;
cin >> choice;
if (choice == 1) {
} else if (choice == 2) {
}else if (choice == 3){
}else if (choice == 4){
break;
}
}
system("PAUSE");
return 0;
}
// List all function definitions here
int displayMenu(int recNum){
cout << "********** Class Roster ******* Total Students = ";
cin >> recNum;
cout << "1. Display all student" << endl;
cout<< "2. Search a student by ID" << endl;
cout << "3. Search a student by Last Name" << endl;
cout << "4. Exit" << endl;
return recNum;
}
void displayStudents(){
}
bool getRecord(int& recNum, int& id, char fname[20], char lname[20], char email[40], double& gpa){
if (recNum==0) {
inStream.open("prog8in.txt");
if (inStream.fail()){
cout<<"File \"prog8in.txt\" cannot be opened."<<endl;
system("pause");
exit(1);
} else cout<<"File \"prog8in.txt\" opened."<<endl;
}
inStream >>id >>fname >>lname >>email >>gpa;
if (inStream.eof()) return false;
else {
recNum++;
return true;
}
}
|