本人解答供参考
#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; }