我对C很新,并且无法弄清楚如何将连续内存分配给结构数组.在这个赋值中,我们给出了代码的shell,并且必须填写其余部分.因此,我无法更改变量名称或函数原型.这是给我的:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
struct student {
int id;
int score;
};
struct student *allocate() {
/* Allocate memory for ten students */
/* return the pointer */
}
int main() {
struct student *stud = allocate();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我只是不确定如何去做那些评论在分配功能中所说的内容.