이번에는 파일을 읽어서 하는건데 이름을 ragged array로 하라길래 포인터에 DMA로 잡았는데 계속 막히네요

뭐가 잘못된건가요;? 배운대로 한거 같은데..


input.txt

065551 쿨쿨쿨 80 60 70
065552 멍멍멍 10 20 30
066663 컹컹컹 20 30 20
067774 엉엉엉 80 60 90
067775 음메에에에 50 60 90
067776 꼬꼬댁 40 60 80
067777 야옹야옹 60 50 80
068888 우가 100 90 90
099999 깔깔깔 10 60 30
069910 훌쩍 90 30 70







#include <stdio.h>
#include <stdlib.h>
#define all_stu 10

typedef struct {
        int number;
        char *name;
        int mid, fin, home;
        double unification;
        char *grade;
} all_sheet;

all_sheet  sheet[all_stu];



void data(int s){

        int i = 0;
        char *fname = "input.txt";

        FILE *input_d;
        if ((input_d = fopen(fname,"r")) == NULL){
                printf("파일이 열리지 않았습니다!!n");
                exit(1);
        }

        for(i=0;i<10;i++){
                sheet[i].name = (char *) calloc(all_stu,sizeof(char));
                fscanf(input_d,"%d %c %d %d %dn",&sheet[i].number,&sheet[i].name,&sheet[i].mid,&sheet[i].fin,&sheet[i].home);
        }

        fclose(input_d);


        
}

void unity(double p){
        int i = all_stu;

        for(i=0;i<10;i++){
                sheet[i].unification = (double)(sheet[i].mid*0.4)+(double)(sheet[i].fin*0.4)+(double)(sheet[i].home*0.2);
        }
        
}

void records(char z){
        int i = all_stu;

        for(i=0;i<10;i++){
                if(sheet[i].unification >= 95) sheet[i].grade = "A+";
                else if(sheet[i].unification >= 90) sheet[i].grade = "A";
                else if(sheet[i].unification >= 85) sheet[i].grade = "B+";
                else if(sheet[i].unification >= 80) sheet[i].grade = "B";
                else if(sheet[i].unification >= 75) sheet[i].grade = "C+";
                else if(sheet[i].unification >= 70) sheet[i].grade = "C";
                else if(sheet[i].unification >= 65) sheet[i].grade = "D+";
                else if(sheet[i].unification >= 60) sheet[i].grade = "D";
                else sheet[i].grade = "F";
                }
}





int main(void)
{
        char z = 0;
        int i = all_stu;
        int s = 0;
        int sum1= 0,sum2 = 0, sum3 = 0;
        double p = 0;
        double ave1 = 0, ave2 = 0, ave3 = 0, ave4 = 0, sum4 = 0;
        

        data(s); /* 학생 데이터 호출 */
        unity(p); /* 통합성적 호출 */
        records(z); /* 학점 호출 */

                


        printf("=========================================================================n");
        printf("학  번   이      름   중간고사  기말고사   숙  제    통합점수   학점n");
        printf("=========================================================================n");

        for(i = 0;i < all_stu;i++){
                printf("%06d   %10s   %5d     %5d     %5d       %5.0lf      %s n", sheet[i].number, sheet[i].name, sheet[i].mid, sheet[i].fin, sheet[i].home, sheet[i].unification, sheet[i].grade);
                
        }
        printf("=========================================================================n");
        
        for(i=0; i<10; i++){
                sum1 += sheet[i].mid;
                sum2 += sheet[i].fin;
                sum3 += sheet[i].home;
                sum4 = sum4 + sheet[i].unification;
        }
        ave1 = (double)(sum1)/(double)(all_stu);
        ave2 = (double)(sum2)/(double)(all_stu);
        ave3 = (double)(sum3)/(double)(all_stu);
        ave4 = sum4/(double)(all_stu);

                
        printf(" 평균                 %5.0f     %5.0f     %5.0f       %5.0fn",ave1, ave2, ave3, ave4);
        printf("=========================================================================n");

        return 0;


}