Question: I don't know what problem with my code and the question is to Write down a program which will create a list (simple linear linked

I don't know what problem with my code and the question is to Write down a program which will create a list (simple linear linked list) of nodes. Each node consists of two fields. The first field is a pointer to a structure that contains a student id (integer) and a grade-point average (float). The second field is a link. The data are to be read from a text file. Your program should read a file of 10 students (with student id and grade point average) and test the function you wrote (by printing students information on screen).

#include

#include

typedef struct node {

int studentId;

float Pointaverage;

struct node* next;

}NODE;

NODE* creatNode(int id, float average)

{

NODE* nodeptr;

nodeptr = (NODE*)malloc(sizeof(NODE));

nodeptr->studentId=id;

nodeptr->Pointaverage = average;

nodeptr->next = NULL;

return nodeptr;

}

int main()

{

NODE* x,*temp;

FILE *fp;

int tempint;

float tempfloat;

fp = fopen_s("lab1txt.txt", "r");

if (fp == NULL)

{

printf("flie open error ");

return 0;

}

fscanf_s(fp, "%d%f", &tempint, &tempfloat);

x->studentId = tempint;

x->Pointaverage = tempfloat;

temp = x;

while (!feof(fp)) {

fscanf_s(fp, "%d%f", &tempint, &tempfloat);

x->next = creatNode(tempint, tempfloat);

x = x->next;

}

while (temp->next != NULL)

{

printf("%d,%f ", temp->studentId, temp->Pointaverage);

temp = temp->next;

}

fclose(fp);

system("pause");

return 0;

}

I don't know what problem with my code and the question is

37 38 39 x-next creatNode (tempint, tempfloat) lab1txt.txt- 100 % (E) 0 1000 4.0 Error List 4 Errors 0 Warnings0 Messages BuildIntelliSense - Search Error List 1001 3.9 1002 3.8 Li... Suppressid 1003 3.7 1004 3.6 1005 3.5 1006 3.4 1007 3.3 1008 3.2 1009 3.1 Code Description Project a value of type "errno. cannot be assigned to an entity of type "FILE argument of type "const char *" is incompatible with parameter of type "FILE ** too few arguments in function call lab1.cpp EO513 E0167 E0165 Lab1 25 Lab1 Lab1 Lab1 lab1.cpp lab1.cpp lab1.cpp 25 25 25 C2660 fopen_s': function does not take 2 arguments Error List Output 37 38 39 x-next creatNode (tempint, tempfloat) lab1txt.txt- 100 % (E) 0 1000 4.0 Error List 4 Errors 0 Warnings0 Messages BuildIntelliSense - Search Error List 1001 3.9 1002 3.8 Li... Suppressid 1003 3.7 1004 3.6 1005 3.5 1006 3.4 1007 3.3 1008 3.2 1009 3.1 Code Description Project a value of type "errno. cannot be assigned to an entity of type "FILE argument of type "const char *" is incompatible with parameter of type "FILE ** too few arguments in function call lab1.cpp EO513 E0167 E0165 Lab1 25 Lab1 Lab1 Lab1 lab1.cpp lab1.cpp lab1.cpp 25 25 25 C2660 fopen_s': function does not take 2 arguments Error List Output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!