Home > Back-end >  Consult C structure of a problem, it's too difficult... ahhhhh!!!!!!
Consult C structure of a problem, it's too difficult... ahhhhh!!!!!!

Time:09-17

Write a program to define a structure type, can store a student's overall performance and a pointer to the structure type, enter the three students overall achievement to the three structure variables, let the first pointer variable types of members to store the address of the second variable, let members of the second variable pointer type third variable storage address, let the third variable pointer types of member's value is NULL, then define a function, the parameters for a structure pointer type, output the three students their overall performance, the function in the call of argument is the address of the first variable,
Then I write code is:
#include
Struct studentinfo
{
Int score;
Struct studentinfo * next;
} st1 st2, st3;
Void Print_Score (struct student * st1)
{
Printf (" st1. \ n score=% d ", st1 - & gt; Score);
Printf (" st2. \ n score=% d ", st1 - & gt; Next - & gt; Score);
Printf (" st3. \ n score=% d ", st1 - & gt; Next - & gt; Score);
}
Int main ()
{
St1. Score=100;
St2. Score=98;
St3. Score=96;
St1. Next=& amp; St2.
St2. Next=& amp; St3;
St3. Next=NULL;
Print_Score (& amp; St1);
return 0;
}
Then the DVC compiler error above, change for a long time did not come out, for bosses to solve!!!!!!!!!!!

CodePudding user response:

Student should be studentinfo

CodePudding user response:

Is a linked list,
Printf (" st3. \ n score=% d ", st1 - & gt; Next - & gt; Score);=="" printf (" st3. Score=% d \ n", st2 - & gt; Next - & gt; Score);

CodePudding user response:

 # include & lt; stdio.h> 

Struct studentinfo
{
Int score;
Struct studentinfo * next;
} st1 st2, st3;

Void Print_Score (struct studentinfo * st1)
{
Printf (" st1. \ n score=% d ", st1 - & gt; Score);
Printf (" st2. \ n score=% d ", st1 - & gt; Next - & gt; Score);
Printf (" st3. \ n score=% d ", st1 - & gt; Next - & gt; Next - & gt; Score);
}

Int main ()
{
St1. Score=100;
St2. Score=98;
St3. Score=96;
St1. Next=& amp; St2.
St2. Next=& amp; St3;
St3. Next=NULL;
Print_Score (& amp; St1);
return 0;
}

For your reference ~

Where Print_Score function parameter type declaration?
  • Related