how do i create a function to update the contents of the student record. The onl
ID: 3757977 • Letter: H
Question
how do i create a function to update the contents of the student record. The only field that should not be able to be updated is the student ID. Create a prompt for the user to enter the student ID number to search for. Create a prompt to determine which field the user wished to update then accept new input for that field and change the contents of the appropriate student. with the structure struct Node { void *nodeData; int nodeLink; }; typedef struct Student { int stuID; char stuName[61]; char stuMajor[5]; double stuGPA;
Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(void)
{
FILE *fp;
struct Node List[15];
int Begin, current, newStuff, oldStuff;
double oldData;
int(*fnPtr)();
Begin = 0;
struct Student *stu;
for (int x = 0; x < 3; x++)
{
newStuff = FindSpace(List);
List[newStuff].nodeData = readData(stdin);
addNode(Begin, List, newStuff);
}
for (int i = Begin; i != -1; i = List[i].nodeLink)
fprintf(stdout,"%.2f ",((Stu*)List[i].nodeData));
for (int i = Begin; i != -1; i = List[i].nodeLink)
free(List[i].nodeData);
}
void updateNode(struct Node List[], int current, int *NewData)
{
int temp1;
List[current].nodeLink = List[*NewData].nodeData;
List[*NewData].nodeLink = NewData;
printf("enter the student ID number ");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.