weixin_慕标4401382
2022-06-02 17:44
#include <stdio.h>
#include <stdlib.h>
struct Score{
int math;
} typedef score;
Score * getScore(){
score * arr = (Score *)malloc(20 * sizeof(Score));
for(int i=0;i<20;i++){
arr[i].math = i;
}
return arr;
}
int main(){
score * arr = getScore();
for(int i=0;i<20;i++){
printf("%d\n",arr[i].math);
}
return 0;
}
malloc的空间后面需要free掉
趣味 C++ 进阶
14584 学习 · 44 问题
相似问题