Sorry for the formatting i formated the code, and i dont;t under what are you saying about NODE * can you please show me i am new to c programming, and this is an assignmnet.
Thanks
Kim
PHP Code:
#include <stdio.h>
#include <string.h>
typedef struct {
float GPA;
char LastName[20];
unsigned int StudentNumber;
}STUDENT;
typedef struct{
STUDENT aStudent;
struct NODE * next;
}NODE;
void * read_list(NODE * pList){
int userStudentNumber =0;
NODE * temp;
temp = pList;
while(userStudentNumber >=0)
{
printf("Please Input Students StudentNumber\n");
scanf("%d",&userStudentNumber);
if(pList==NULL)
{
if(!(pList = (NODE*) malloc(sizeof(NODE)))){
exit(100);
}
temp = pList;
}
else
{
while((temp->next)!=NULL)
{
temp=temp->next;
}
temp->next = malloc(sizeof(NODE));
temp=temp->next;
}
temp->aStudent.StudentNumber = userStudentNumber;
temp->next = NULL;
}
temp->next = NULL;
}
void output_list(NODE * pList){
while(pList!=NULL)
{
printf(" Data : %d",pList->aStudent.StudentNumber);
printf(" Link : %d",pList->next);
pList=pList->next;
}
}
int main(void){
NODE * head = NULL;
head = read_list(head);
output_list(head);
return 0;
}