Hello, first time here.This program reads in a file of different names and uses void options to put them in various order. On line 111, 116, 121, 126, 131, I am not sure what to put inside the parenthesis. [EX: option1(NotSureWhatToPut)]. I have tried to put 'nextStudent' and get a conversion error. What am i doing wrong. Any help would be much Appreciated!
P.S. this program is unfinished. I have yet to complete the Void options.
#include <iomanip>
#include <iostream>
#include <fstream>
#include <cstring> // string function library
using namespace std;
struct StudentRecord
{
char lastName [16]; // field definitions of the structure
char firstName[16];
char hometown [16];
char major[5];
int studentNumber;
double balance;
int earnedHours;
double gpa;
};
void hitEnter();
void displayMenu();
void option1(StudentRecord s[], int n);
void option2(StudentRecord s[], int n);
void option3(StudentRecord s[], int n);
void option4(StudentRecord s[], int n);
void option5(StudentRecord s[], int n);
int main ()
{
char textFilename[50];
StudentRecord nextStudent; // one instance of Studentrecord
StudentRecord student[200]; // arrayof 200 StudentRecords
int n; // counts number of elements in student array
ifstream textFile; // an object in istream can be read only
char lastIn [16]; // Places to read data from the text file
char firstIn[16]; // These correspond to the fields of StudentRecord
char townIn [16];
char majorIn[5];
int numberIn;
double balanceIn;
int hoursIn;
double gpaIn;
cout << "Size of StudentRecord type = " << sizeof(StudentRecord) << endl;
cout << "Remove this temporary output" << endl << endl;
/* First phase: read text file data and create array of student records */
cout << "Enter filename of source text file: ";
cin >> textFilename;
cout << endl;
textFile.open (textFilename);
hitEnter();
n = 0; // maintain count of student records in the file
while (!textFile.eof())
{
textFile >> lastIn >> firstIn >> townIn >> majorIn >> numberIn
>> balanceIn >> hoursIn >> gpaIn;
if (!textFile.eof()) //
{
strcpy (nextStudent.lastName, lastIn); // string copy function
strcpy (nextStudent.firstName, firstIn);
strcpy (nextStudent.hometown, townIn);
strcpy (nextStudent.major, majorIn);
nextStudent.studentNumber = numberIn;
nextStudent.balance = balanceIn;
nextStudent.earnedHours = hoursIn;
nextStudent.gpa = gpaIn;
student[n] = nextStudent;
n++;
}
} // end while loop
cout << "Number of student records created = " << n << endl;
cout << endl;
textFile.close();
/* Second phase: display student records in two ways (temporary code) */
cout << "Student Names Using Array Notation (temp output)" << endl << endl;
for (int i=0; i < n; i++)
{
cout << setw(3) << right << i+1 << ". ";
cout <<setw(16) << left << student[i].firstName << " " << student[i].lastName << endl;
if ((i+1) % 10 == 0) hitEnter();
}
cout << endl<< endl;
hitEnter();
bool programActive = true;
char response;
bool menuActive;
char menuChoice;
char ch;
while (programActive)
{
menuActive = true;
while (menuActive)
{
displayMenu (); // call displayMenu function
cout << "Enter user choice: ";
cin >> menuChoice;
cin.ignore(80,'\n');
cout << endl;
switch (menuChoice)
{
case '1': case 'a': case 'A':
option1();//???????????????????
cout << "Hit <Enter> to return to menu: ";
cin.get(ch);
break;
case '2': case 'd': case 'D':
option2;//?????????????
cout << "Hit <Enter> to return to menu: ";
cin.get(ch);
break;
case '3': case 'l': case 'L':
option3;
cout<<"Hit <Enter> to return to menu: ";
cin.get(ch);
break;
case '4': case 'n': case 'N':
option4;
cout << "Hit <Enter> to return to menu: ";
cin.get(ch);
break;
case '5': case 'c': case 'C':
option5;
cout << "Hit <Enter> to return to menu: ";
cin.get(ch);
break;
case '6': case 'Q': case 'q':
menuActive = false;
break;
default:
cout << "Invalid menu choice!" << endl << endl;
cout << "Hit <Enter> to return to menu: ";
cin.ignore(80,'\n');
}
}
cout << "Menu exited. Continue program? y/n & <Enter>: ";
cin >> response;
if (response == 'n')
programActive = false;
}
return 0;
} // end main function
void hitEnter ()
{
char response;
cout << "\n Hit <Enter> to continue: ";
cin.get(response);
cout << endl;
}
void displayMenu ()
{
cout << endl;
cout << " *************************************************" << endl;
cout << " * *" << endl;
cout << " * M A I N M E N U *" << endl;
cout << " * *" << endl;
cout << " * 1) Option 1: *" << endl;
cout << " * 2) Option 2: *" << endl;
cout << " * 3) Option 3: *" << endl;
cout << " * 4) option 4: *" << endl;
cout << " * 5) option 5: *" << endl;
cout << " * 6) option 6: *" << endl;
cout << " * *" << endl;
cout << " *************************************************" << endl << endl;
} // end displayMenu function
void option1(StudentRecord s[], int n)
{}
void option2(StudentRecord s[], int n)
{}
void option3(StudentRecord s[], int n)
{}
void option4(StudentRecord s[], int n)
{}
void option5(StudentRecord s[], int n)
{}