Home > Back-end >  What a great god help have a look at what point is wrong.
What a great god help have a look at what point is wrong.

Time:05-22

CodePudding user response:

Struct studeng stud [n]. There are problems, n is a random value, not sure size; C language does not support the uncertain array length;
Can consider to use to implement the dynamic application space way:

 struct studeng * stud=NULL; 


Behind the scanf added statements for space:
 
Stud=(struct student *) malloc (sizeof (struct student));
if (! Stud)
exit(0);


After facing the stud can be in the form of an array to access and manipulate;

When the last note shall not apply to the stud, remember to free (stud); Release;

CodePudding user response:

The
reference 1/f, confident boy reply:
struct studeng stud [n]. There are problems, n is a random value, not sure size; C language does not support the uncertain array length;
Can consider to use to implement the dynamic application space way:

 struct studeng * stud=NULL; 


Behind the scanf added statements for space:
 
Stud=(struct student *) malloc (sizeof (struct student));
if (! Stud)
exit(0);


After facing the stud can be in the form of an array to access and manipulate;

When the last note shall not apply to the stud, remember to free (stud); Release;


 stud=(struct student *) malloc (sizeof (struct student) * n); 
if (! Stud)
exit(0);

With this, the above that there is a problem, forget to take the n, after the n is the input of n;
  • Related