I am trying to use the getline function in order to have a user input a students name. The code is as followed.
The Structure:
Code:
struct student // the student structure meant to hold all student data
// in a linked list fashion
{
char studentNames[maxStudents][lnName]; // student names
int sectionNum; // section the student is in
float project[11]; // student's projects
float test[3]; // students's tests
float quiz[5]; // students's quizzes
student *nxt; // pointer to next student
}; // end struct student
The Function:
Code:
void getStudentNames (char pgmID[], char title[], char subTitle[],
char gradebookName[] )
{
// Declare local vbls for holding data that is inputted by the user.
int numStudents;
student *temp;
// Display title and sub-title lines.
system ("cls");
cout << pgmID << setw ( 40 + strlen(title) / 2 - strlen(pgmID)) << title << endl;
cout << setw ( 40 + strlen(subTitle) / 2) << subTitle << "\n\n\n";
// If warranted, open the file for output.
ofstream gradeBookFile;
gradeBookFile.open (gradebookName, ios::out);
// Input data for this item from the user and output it to the database.
cout << "\t\tPlease enter the number of students: ";
cin >> numStudents;
cin.ignore();
// Input data for this item from the user and output it to the database.
for ( int count = 0; count < numStudents; count++ )
{
cout << "\n\t\tPlease enter student name (L F MI): ";
temp = new student;
cin.getline ( temp[count] ->studentNames, lnName );
gradeBookFile << temp->studentNames[count] << endl;
} // end for ( int count = 0 ....
// Close the file, return to sender.
gradeBookFile.close();
} // end getStudentNames (...
The error is at the getline function.
I don't know how to properly do this HELP PLEASE!