做学生成绩管理系统的时候,用fprintf输出到文件时输出一堆数字 -2147483648

做学生成绩管理系统的时候,用fprintf输出到文件时输出一堆数字 -2147483648

typedef struct student
{
    int num;
    string name; 
    float mscore, cscore, escore, average;
    int changshu = 90;
}stu;
typedef struct studentlist
{
   //学生数组
    stu  studentarray[max];
    //当前记录学生个数
    int size=0;
}list;
void outputfile(list*a)
{
    FILE* fp = fopen("C:\\Users\\木木\\Desktop\\test.txt", "a+");
    if (fp == NULL)
    {
        printf("打开文件失败\n");
    }
    fprintf(fp,"%d,%c,%d,%d,%d,%d\n",
        a->studentarray[a->size].num , a->studentarray[a->size].name, a->studentarray[a->size].mscore ,
        a->studentarray[a->size].cscore ,a->studentarray[a->size].escore , a->studentarray[a->size].average );
    fclose(fp);
}

int main()
{
outputfile(a);
}
输出一堆数字0, ,-2147483648,-2147483648,-2147483648,-2147483648
实在是没有办法,我的程序挺多的,这里只放出来一个模块,没办法去掉指针
希望能够输出正常的字符,或者可以用其他的函数将数据输出到文本文件,谢谢!

a->size越界了,改为a->size-1

a->studentarray[a->size].name 用%s输出