STANDARD TEMPLATE LIBRARY: A university stores database of Students n a. dat fil
ID: 3853777 • Letter: S
Question
STANDARD TEMPLATE LIBRARY: A university stores database of Students n a. dat file called "schoolrecords.dat" with a format: First Name Last Name Grades ID You are tasked to create a structure named Student with four-member variables to store parameters. In Main function: a.) Declare an STL list to store the data in the file. b.) Read the file one line of data at a time c.) Store data in the list. Design two parameterized functions for: A. Removing an entry by ID specified by the user Function accepts the ID of an Student, search the list for the ID and then erase that entry. Function call: RemoveEntryForID(I1, 5126689): B. Display Student last name starting with a user defined character. Function accepts a character, search the last names of Students starting with the user defined character and displays entry and list of last names that start with that character. Function call: LastNameSearch(I1, 's');Explanation / Answer
int main()
{
/* your declaration goes here */
/* declaretion of list */
struct Student {
char FirstName[15]; /* You can use pointer to string */
char LastName[15]
float Grades ; /* It may char /int /float depemding on grade type latter grade or numeric grade*/
int ID; /* it type depend hoe ID is given by university
struct Student *next; /* pointer for next iyem in the list*/
};
}
void RemoveEntryID(struct student *ptr, int n) /* the type of second perameter depend on type ID*/
{
struct Student *temp;
while(ptr->next != NULL)
{
temp=ptr; /*hold the address of current item in the list to link the list if next itme need to be deleted*/
if(ptr->ID== n)
{
temp->next=ptr->next; /* if Id match them we need to modify the next pointer of the previos node .
}
else
ptr=ptr->next; /*to check if the next item in the list match the ID
}
}
void LastNameSearch(struct student *ptr, char c) /* the type of second perameter depend on type ID*/
{
while(ptr->next != NULL)
{
if(ptr->LastName[1]== c) /*we need to chack the first charater i n tha last name
{
cout<< ptr->LastName;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.