Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

===== The HogwartsSWW class will be provided by the instructor ===== 1.0 Overvie

ID: 3856711 • Letter: #

Question

===== The HogwartsSWW class will be provided by the instructor =====

1.0 Overview Professor Albus Dumbledore, headmaster of Hogwarts School of Witchcraft and Wizardry would like to continue his introduction of Computational Magic to the faculty by having a program developed which will maintain lists of all students assigned to each house by the sorting hat. 2.0 Requirements The student shall define, develop, document, prototype, test, and modify as required the software system. 2.1 This software system shall define two classes, called House (file names shall be House.h and House.cpp) and HogwartsSWW (file names shall be HogwartsSWW.h and HogwartsSWW.cpp). Details of these classes are given below. 2.1.1 The House class shall implement a linked list of instances of a class of type Student (see section 2.2). 2.1.1.1 The House class shall contain the following member variables. 2.1.1.1.1 A private pointer called m_pHead to a Student class instance which shall point to the first student in the list. 2.1.1.1.2 A private character array called m_sHouseName capable of holding strings of up to 64 characters which shall store the name of the house. 2.1.1.2 The House class shall contain the following public functions. 2.1.1.2.1 House() and ~House() - A default constructor and destructor. The constructor should set the head pointer to NULL and the house name to an empty string. 2.1.1.2.2 bool AddStudent(Student *stu) - this function shall take a pointer to an instance of the Student class as the only argument. This instance of Student shall already have all data inserted into it. The function shall insert the student into the list of students in order by student number and return true if it successfully added the student. 2.1.1.2.3 Student *RemoveStudent(int studentID) - this function shall take an integer giving a student ID number as the only argument. It shall search the list for the student and remove the student from the list. If the student was found it shall return that instance of Student removed from the list, otherwise it shall return NULL. 2.1.1.2.4 Student *FindStudent(int studentID) - this function shall take an integer giving a student ID number as the only argument. It shall search the list for the student and if found return a pointer to a duplicate of the Student class instance that was found. If the student was not found the function shall return NULL. 2.1.1.2.5 Student *FindStudent(char *fname, char *lname) - this function shall take, as arguments, character arrays giving the first and last name of a student. It shall search the list for the student and if found return a pointer to a duplicate instance of the Student class instance that was found, i.e. if found the function will create a duplicate of that instance of Student with all data identical to the one found in the list, except for the "next" pointer. It shall then return a pointer to this duplicate instance. If the student was not found the function shall return NULL. 2.1.1.2.6 void PrintHouseList() - this function shall print all information on all students in the list by calling the printStudentInfo() function in each Student found in the list. 2.1.1.2.7 void SetHouseName(char *name) and char *GetHouseName() which shall be used to Set and Get the name of the house. 2.1.2 The HogwartsSWW class shall maintain pointers to four instances of the House class. It shall dynamically allocate memory for these four instances in the constructor and set the names of the houses to "Gryffindor", "Ravenclaw", "Hufflepuff", and "Slytherin" respectively. 2.1.2.1 The HogwartsSWW class shall contain the following public functions. 2.1.2.1.1 HogwartsSWW() and ~HogwartsSWW() - A default constructor and destructor. The constructor should set all the pointers to instances of House and assign each House a name. 2.1.2.1.2 bool AddStudent(Student *stu) - this function shall take one argument which shall be a pointer to an instance of the Student class in which all data has already been set. This function shall locate the appropriate instance of the House class and pass the student class instance to its' AddStudent() function. It shall return TRUE if the correct house was located and the student inserted or FALSE otherwise. 2.1.2.1.3 Student *RemoveStudent(char *house, int studentID) - this function shall take two arguments. The first shall be a character array giving the name of one of the four houses. The second argument shall be an integer giving a student ID number. This function shall locate the appropriate instance of the House class and pass the student ID to its' RemoveStudent() function. It shall return the pointer to Student returned by this call. 2.1.2.1.4 Student *FindStudent(char *house, int studentID) - this function shall take two arguments. The first shall be a character array giving the name of one of the four houses. The second argument shall be an integer giving a student ID number. This function shall locate the appropriate instance of the House class and pass the student ID to its' FindStudent() function. It shall return the pointer to Student returned by this call. 2.1.2.1.5 Student *FindStudent(char *house, char *fname, char *lname) - this function shall take three arguments. The first shall be a character array giving the name of one of the four houses. The second and third arguments shall give the first and last name of a student. This function shall locate the appropriate instance of the House class and pass the student name arguments to its' FindStudent() function. It shall return the pointer to Student returned by this call. 2.1.2.1.6 void PrintHouses() - this function shall call the PrintHouseList() function in each of the instances of House.

===== The HogwartsSWW class will be provided by the instructor =====

2.2 This software system shall modify the Student class created in programming assignment 1 in the following way. 2.2.1 The Student class shall have added a public pointer, called m_pNext capable of holding the address of a Student object so that a linked list of Student objects can be constructed. This pointer should be set to NULL in both constructors. 2.2.2 The Student class shall have added a public function, Student *Clone() which shall create a deep copy of itself and return a pointer to the copy. 2.3 The source files for the three classes (Student, House and HogwartsSWW) and their associated header files must be capable of being compiled and linked in with a driver program (main() in a separate file) for testing. 3.0 Deliverables These products shall be delivered to the instructor electronically via e-mail as specified below.
3.1 Sprint Report -- The student shall provide filled out Sprint Report form for instructor approval NLT (Not Later Than) Monday, July 10.
3.2 Program source files -- The student shall provide fully tested electronic copies of the .cpp and .h files. These files must be submitted to the instructor via e-mail. The files shall be delivered NLT Monday, July 10. 4.0 Period of Performance The period of performance of this assignment is 14 days from the date of assignment. Files that will not compile will not be accepted. If an error is found during testing the instructor will report the error and give you a chance to correct the error and resubmit the files as long as the files are turned in before the DDD.

Explanation / Answer

HogwartsSWW.cpp
------------------------------
#include "HogwartsSWW.h"
#include <iostream>
#include <stdio.h>

using namespace std;

//-----------------------------------------------------
// Default constructor
//-----------------------------------------------------
HogwartsSWW::HogwartsSWW()
{
   m_pGryffindor = new House();
   m_pGryffindor->SetHouseName("Gryffindor");
   m_pRavenclaw = new House();
   m_pRavenclaw->SetHouseName("Ravenclaw");
   m_pHufflepuff = new House();
   m_pHufflepuff->SetHouseName("Hufflepuff");
   m_pSlytherin = new House();
   m_pSlytherin->SetHouseName("Slytherin");
}

//-----------------------------------------------------
// Destructor
//-----------------------------------------------------
HogwartsSWW::~HogwartsSWW()
{
   delete m_pGryffindor;
   delete m_pRavenclaw;
   delete m_pHufflepuff;
   delete m_pSlytherin;
}

//-----------------------------------------------------
// AddStudent()
// Purpose: Add a student to a house
// Args: stu - pointer to a Student object
// Returns: bool - true if add was successful
//-----------------------------------------------------
bool HogwartsSWW::AddStudent(Student *stu)
{
   char house[64];
   stu->getHouse(house);

   if(strcmp(house, "Gryffindor") == 0)
       return m_pGryffindor->AddStudent(stu);
   else if(strcmp(house, "Ravenclaw") == 0)
       return m_pRavenclaw->AddStudent(stu);
   else if(strcmp(house, "Hufflepuff") == 0)
       return m_pHufflepuff->AddStudent(stu);
   else if(strcmp(house, "Slytherin") == 0)
       return m_pSlytherin->AddStudent(stu);
   else
       return false;
}

//-----------------------------------------------------
// RemoveStudent()
// Purpose: Remove a student from a house
// Args: house - Name of the student's house
//       stu - pointer to a Student object
// Returns: bool - true if removal was successful
//-----------------------------------------------------
bool HogwartsSWW::RemoveStudent(char *house, int studentID)
{
   if(strcmp(house, "Gryffindor") == 0)
       return m_pGryffindor->RemoveStudent(studentID);
   else if(strcmp(house, "Ravenclaw") == 0)
       return m_pRavenclaw->RemoveStudent(studentID);
   else if(strcmp(house, "Hufflepuff") == 0)
       return m_pHufflepuff->RemoveStudent(studentID);
   else if(strcmp(house, "Slytherin") == 0)
       return m_pSlytherin->RemoveStudent(studentID);
   else
   {
       cout << "Unknown house given in RemoveStudent() function. ";
       return false;
   }
}

//-----------------------------------------------------
// FindStudent()
// Purpose: Find a student in a house
// Args: house - Name of the student's house
//       stu - pointer to a Student object
// Returns: Pointer to a clone of the student record
//-----------------------------------------------------
Student *HogwartsSWW::FindStudent(char *house, int studentID)
{
   if(strcmp(house, "Gryffindor") == 0)
       return m_pGryffindor->FindStudent(studentID);
   else if(strcmp(house, "Ravenclaw") == 0)
       return m_pRavenclaw->FindStudent(studentID);
   else if(strcmp(house, "Hufflepuff") == 0)
       return m_pHufflepuff->FindStudent(studentID);
   else if(strcmp(house, "Slytherin") == 0)
       return m_pSlytherin->FindStudent(studentID);
   else
   {
       cout << "Unknown house given in FindStudent(char *, int) function. ";
       return NULL;
   }
}

//-----------------------------------------------------
// FindStudent()
// Purpose: Find a student in a house
// Args: house - Name of the student's house
//       fname - Student's first name
//       lname - Student's last name
// Returns: Pointer to a clone of the student record
//-----------------------------------------------------
Student *HogwartsSWW::FindStudent(char *house, char *fname, char *lname)
{
   if(strcmp(house, "Gryffindor") == 0)
       return m_pGryffindor->FindStudent(fname, lname);
   else if(strcmp(house, "Ravenclaw") == 0)
       return m_pRavenclaw->FindStudent(fname, lname);
   else if(strcmp(house, "Hufflepuff") == 0)
       return m_pHufflepuff->FindStudent(fname, lname);
   else if(strcmp(house, "Slytherin") == 0)
       return m_pSlytherin->FindStudent(fname, lname);
   else
   {
       cout << "Unknown house given in FindStudent(char *, char *, char *) function. ";
       return NULL;
   }
}


//-----------------------------------------------------
// PrintHouses()
// Purpose: Print all information on all students in
//               all houses
// Args: None
// Returns: void
//-----------------------------------------------------
void HogwartsSWW::PrintHouses()
{
   cout << "Students at Hogwarts ";
   m_pGryffindor->PrintHouseList();
   cout << " Press any key to see the next house listing...";
   getchar();
   cout << " ";
   m_pRavenclaw->PrintHouseList();
   cout << " Press any key to see the next house listing...";
   getchar();
   cout << " ";
   m_pHufflepuff->PrintHouseList();
   cout << " Press any key to see the next house listing...";
   getchar();
   cout << " ";
   m_pSlytherin->PrintHouseList();
}
---------------------------------------------------
HogwartsSWW.h
------------------------------
#define HOGWARTSSWW_H

#include "House.h"
#include "Student.h"

class HogwartsSWW
{
   private:
       House   *m_pGryffindor;
       House   *m_pRavenclaw;
       House   *m_pHufflepuff;
       House   *m_pSlytherin;

   public:
       HogwartsSWW();                                   // Default constructor
       ~HogwartsSWW();                                   // Destructor
       bool AddStudent(Student *stu);                   // Add a student to a house
       bool RemoveStudent(char *house, int studentID); // Remove a student given an ID
       Student *FindStudent(char *house, int studentID);// Find a student given the student ID
       Student *FindStudent(char *house, char *fname,   // Overloadef find function. Find a student
                       char *lname);                     //   given the first and last names
       void PrintHouses();
};
#endif
---------------------------------------------------
House.cpp
------------------------------
#include "Student.h"
#include "House.h"
#include<string.h>
#include<iostream>
using namespace std;

House::House()
{
head = NULL;
}

House::~House()
{
Student *temp;
  
   if(!(head==NULL))
       {
           temp = head;
           while (head != NULL)
           {
               temp = head;
               head = head->m_pNext;
               delete temp;
           }
       }

}

bool House::AddStudent(Student *stu)
{
  
  
   if(head == NULL)
   {
       head = stu;  
       return true;
   }
  
   else if((stu->getStudentID)<(head->getStudentID))
   {
       stu->m_pNext = head;
       head = stu;
       return true;
   }
  
   else if((stu->getStudentID)>(head->getStudentID))
   {
       Student *tempStu = head;
       Student *backStu = NULL;
      
       while((tempStu!=NULL)&&((tempStu->getStudentID)<(stu->getStudentID)))
       {
       backStu=tempStu;
       tempStu = tempStu->m_pNext;
       }
       backStu->m_pNext = stu;
       stu->m_pNext=tempStu;
   }
   return true;
}

bool House::RemoveStudent(int studentID)
{
   if (head==NULL)
   {
       return false;
   }

   Student *tempStu = head;
   Student *backStu = NULL;
  
   while((tempStu!=NULL)&&((tempStu->getStudentID)!=(studentID)))
       {
       backStu=tempStu;
       tempStu = tempStu->m_pNext;
       }

   if (backStu==NULL)
   {
       head = head->m_pNext;
       delete tempStu;
       return true;
   }

   else if ((tempStu!=NULL)&&((tempStu->getStudentID)==(studentID)))
   {
       backStu->m_pNext = tempStu->m_pNext;
       delete tempStu;
       return true;
   }

}

Student *House::FindStudent(int studentID)
{
   if(head == NULL)
   {
       return NULL;
   }
  
   Student *tempStu = head;
  
   while(tempStu!=NULL)
   {
       if((tempStu->getStudentID)!=(studentID))
       {
           tempStu = tempStu->m_pNext;
       }
          
       else if((tempStu->getStudentID)==(studentID))
       {
           return tempStu->Clone;
       }
   }

   if (tempStu == NULL)
   {
       return NULL;
   }
}
  

Student *House::FindStudent(char *fname, char* lname)
{
   if(head == NULL)
   {
       return NULL;
   }
  
   Student *tempStu = head;
   char tempFname[65], tempLname[65];

   while(tempStu!=NULL)
   {
       tempStu->getName(tempFname, tempLname);
       if(strcmp(tempLname, lname)!=0)
       {
           tempStu = tempStu->m_pNext;
       }  
       else if((strcmp(tempLname, lname)==0)&&(strcmp(tempLname, lname)==0))
       {
           return tempStu->Clone;
       }
   }

}

void House::PrintHouseList()
{

   cout<<"House ";
   for (int i = 0;i = strlen(hName);i++)
   {
       cout<<hName[i];
   }

   cout<<endl<<"*************************"<<endl<<endl;
   Student *tempStu = head;
   while(tempStu!=NULL)
   {
       tempStu->printStudentInfo;
       tempStu=tempStu->m_pNext;
       cout<<endl<<"*************************"<<endl<<endl;
   }
}
      
void House::SetHouseName(char *name)
{
   strcpy(hName, name);
}

char *House::GetHouseName()
{
   return hName;
}
---------------------------------------------------
House.h
------------------------------
#pragma once

#include "Student.h"

class House
{
   private:
       Student *head;
       char hName[];

   public:
       House();
       ~House();
       bool AddStudent(Student *stu);
       bool RemoveStudent(int studentID);
      
       Student *FindStudent(int studentID);
       Student *FindStudent(char *fname, char* lname);
      
       void PrintHouseList();
      
       void SetHouseName(char *name);
       char *GetHouseName();


};
---------------------------------------------------
Student.cpp
------------------------------
#include"Student.h"
#include<string.h>
#include<iostream>
using namespace std;


//Default Constructor
Student::Student()
{
   //set all Class variables to NULL;
   m_iStudentID = 0;
   for (int i=0; i < int(strlen(m_sMagicalName));i++)
       {
           m_sMagicalName[i]=NULL;
       }
  
   for (int i=0; i < int(strlen(m_sWizardFamilyName));i++)
       {
           m_sWizardFamilyName[i]=NULL;
       }
  
   for (int i=0; i < int(strlen(m_sHouse));i++)
       {
           m_sHouse[i]=NULL;
       }
  
   for (int i=0;i<8;i++)
       {          
           m_sClasses[i]=NULL;  
       }
  
   for (int i=0;i<8;i++)
       {
           m_iGrades[i]=0;
       }
}

//Parametrized Conststructor sets Class variables to StudentID, Name, and House, other variables set to Nul
Student::Student(int iID, char *mName, char *wName, char *hName)
{
   m_iStudentID = iID;
   strcpy(m_sMagicalName, mName);
   strcpy(m_sWizardFamilyName, wName);
   strcpy(m_sHouse, hName);
  
   for (int i=0;i<8;i++)
   {  
       m_sClasses[i]=NULL;  
   }
  
   for (int i=0;i<8;i++)
   {
       m_iGrades[i]=0;
   }
}

//Class Destructor
Student::~Student()
{
  
   //Clear dynamically allocated memory for array of pointers to Class Name character arrays
   for(int i = 0;i<8;i++)
   {
       if(m_sClasses[i]!=NULL)
       {

       delete[] m_sClasses[i];
       }
   }

}

Student *Student::Clone()
{
  
   Student *tempStu = new Student;
   tempStu->setStudentID(m_iStudentID);
   tempStu->setName(m_sMagicalName, m_sWizardFamilyName);
   tempStu->setHouse(m_sHouse);
  
   for(int i=0;i<8;i++)
   {
       if(m_sClasses[i] != NULL)
       {
       tempStu->setClass(i, m_sClasses[i]);
       tempStu->setGrade(i, m_iGrades[i]);
       }
   }
   return tempStu;
  
}

//get StudentID returns student ID no. variable
int Student::getStudentID()
{
   return m_iStudentID;
}

//set Student ID sets student ID class variable to passed argument
void Student::setStudentID(int iID)
{
   m_iStudentID = iID;
}

//get Name retrieves class variable in form of char arrays, for student's first and last name, copies to character array arguments
void Student::getName(char *mName, char*wName)
{
   strcpy(mName, m_sMagicalName);
   strcpy(wName, m_sWizardFamilyName);
}

//set Name function copies char array argument to the appropriate variable in the Student Class
void Student::setName(char *mName, char*wName)
{
   strcpy(m_sMagicalName, mName);
   strcpy(m_sWizardFamilyName, wName);
}

//get house function copies class variable for student's house name to argument pointing to character array
void Student::getHouse(char *hName)
{
   strcpy(hName, m_sHouse);
}


//set house function copies argument pointing to character array to Student class variable for House Name
void Student::setHouse(char *hName)
{
   strcpy(m_sHouse, hName);
  
}

//get Class copies char array for student's class at argument: idx out of pointer array: m_sClasses[] to argument: character array className
void Student::getClass(int idx, char *className)
{
   if((idx>=0)&&(idx<8))
   {
       if(m_sClasses[idx]!=NULL)
           {
           strcpy(className, m_sClasses[idx]);
           }
   }
}

//set Class copies char array argument className for student's class to argument: idx out of pointer array: m_sClasses[]
void Student::setClass(int idx, char *className)
{
   if((idx>=0)&&(idx<8))
   {
       if(m_sClasses[idx]!=NULL)
           {
               delete m_sClasses[idx];
           }
       m_sClasses[idx] = new char[strlen(className)+1];
       strcpy(m_sClasses[idx], className);
   }
}

//get Grade function gets student's integer grade at appropriate index of array, copies to argument iGrade, if statements check ranges to determine letter grade and set to char cGrade
void Student::getGrade(int idx, int &iGrade, char &cGrade)
{
   if((idx>=0)&&(idx<8))
   {
       iGrade = m_iGrades[idx];
       if (iGrade>=95)
       {
           cGrade='O';
       }
       else if ((iGrade>=90)&&(iGrade<95))
       {
           cGrade='E';
       }
       else if ((iGrade>=80)&&(iGrade<90))
       {
           cGrade='A';
       }
       else if ((iGrade>=70)&&(iGrade<80))
       {
           cGrade='P';
       }
       else if ((iGrade>=60)&&(iGrade<70))
       {
           cGrade='D';
       }
       else if(iGrade<60)
       {
           cGrade='T';
       }
   }
}

//set Grade function sets student's grade at appropriate index of m_iGrades array
void Student::setGrade(int idx, int grade)
{
   if((idx>=0)&&(idx<8))
   {
       m_iGrades[idx] = grade;
   }
}

//prints all student info in appropriate format
void Student::printStudentInfo()
{
   //Print Student ID no.
   cout<<"Student ID#:   "<<m_iStudentID<<endl;
  
   //Print Student Name: Last, First
   cout<<"Student Name:   ";
   for (int i=0; i < int(strlen(m_sWizardFamilyName));i++)
       {
           cout<<m_sWizardFamilyName[i];
       }
  
   cout<<", ";
  
   for (int i=0; i < int(strlen(m_sMagicalName));i++)
       {
           cout<<m_sMagicalName[i];
       }
  
   cout<<endl;
  
   //Print Student House name
   cout<<"Student House:   ";
   for (int i=0; i < int(strlen(m_sHouse));i++)
   {
       cout<<m_sHouse[i];
   }
  
   //Print Student Classes and Grades
   char tempS[65];//character array for printing each class
   char charGrade;//variable to hold each letter grade
   int intGrade;//variable to hold each class's integer grade
   cout<<endl<<endl<<"CLASSES       GRADES"<<endl;
  
   for (int i=0; i<8; i++)
       {
           //output student's classes
           if(m_sClasses[i]!=NULL)
           {
               strcpy(tempS, m_sClasses[i]);
               for (int j=0;j<strlen(tempS);j++)
               {
                   cout<<tempS[j];
               }
               //output students integer and letter grade
               getGrade(i, intGrade, charGrade);
               cout<<"       "<<intGrade<<"   "<<charGrade<<endl;
           }
       }

}
---------------------------------------------------
Student.h
------------------------------
#pragma once

class Student
{
private:
   int m_iStudentID;//Student ID number
   char m_sMagicalName[65];//char array for student's first name
   char m_sWizardFamilyName[65];//char array for student's last name
   char m_sHouse[65];//char array for student's house name
   char *m_sClasses[8];//array of pointers to char arrays for student's classes
   int m_iGrades[8];//array of integers for student's classes

public:
   Student *m_pNext;
  
  
   Student();//default constructor
   Student(int iID, char *mName, char *wName, char *hName);//paremetrized constructor
   ~Student();//destructor
  
   Student *Clone();
   //get and set student id variable
   int getStudentID();
   void setStudentID(int iID);
  
   //get and set first and last name variables
   void getName(char *mName, char*wName);
   void setName(char *mName, char*wName);
  
   //get and set house name array
   void getHouse(char *hName);
   void setHouse(char *hName);
  
   //get and set classes from an array of eight pointers
   void getClass(int idx, char *className);
   void setClass(int idx, char *className);
  
   //get and set integer and letter grades for each class
   void getGrade(int idx, int &iGrade, char &cGrade);
   void setGrade(int idx, int grade);
  
   //print all student info
   void printStudentInfo();
};
---------------------------------------------------
TestInDaHouse.cpp
------------------------------
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include "HogwartsSWW.h"
#include "Student.h"
#include "House.h"

using namespace std;

// Prototype functions to read lines from the file and build the houses
bool getNextLine(char *line, int lineLen);
void buildStudentLists(HogwartsSWW *h);

ifstream   inFile;   // File to read from

// Define the name of the file to read from
#define STUDENT_FILE "students.txt"

//*/========================================================
//
//2. Add the following functions below main()
//
//*/========================================================
void buildStudentLists(HogwartsSWW *h)
{   
   char line[128];// Declare a character array to hold lines read from file
   Student *s;
   char fname[32];
   char lname[32];
   int numClasses;

   // Open the data file
   inFile.open(STUDENT_FILE, ifstream::in);
   if(!inFile.is_open())
   {
       cout << "Failed to open file: " << STUDENT_FILE << " application terminating. ";
       exit(0);
       }
   while(getNextLine(line, 128))
   {
       s = new Student();       // Create a new student
       s->setStudentID(atoi(line));   // Set the ID

       // Read and parse student name
       getNextLine(line, 128);
       sscanf(line, "%s %s", fname, lname);
       s->setName(fname, lname);

       // Read and parse house name
       getNextLine(line, 128);
       s->setHouse(line);

       // Read all classes
       getNextLine(line, 128);   // Read and parse number of classes
       numClasses = atoi(line);
       for(int i=0; i<numClasses; i++)
       {
           getNextLine(line, 128); // Get name of class
           s->setClass(i, line);
           getNextLine(line, 128); // Get grade
           s->setGrade(i, atoi(line));
       }

       // Add this student to the school
       h->AddStudent(s);
   }
}

//-------------------------------------------
// GetNextLine()
// Read the next line from the file.
//-------------------------------------------
bool getNextLine(char *line, int lineLen)
{
    int    done = false;

    while(!done)
    {
        inFile.getline(line, lineLen);
      
        if(inFile.good())    // If a line was successfully read
        {
           if(strlen(line) == 0) // Skip any blank lines
                continue;
            else if(line[0] == '#') // Skip any comment lines
                continue;
            else done = true;    // Got a valid data line so return
                                 // with this line
        }
        else
        {
            strcpy(line, "");
            return false;
        }
    } // end while
    return true;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote