Как передать в функцию структуру?

я объявил в main.c структуру

typedef struct student {
    char *name;
    char number_of_group[8];
    double score;
};

хочу передать в процедуру эту структуру

void console_output(struct student *mephist , int count_of_elements){
    int i = 0;
    while (i < count_of_elements) {
        printf("%s\n", mephist[i].name);
        printf("%s\n", mephist[i].number_of_group);
        printf("%f\n", mephist[i].score);
        i++;
    }
}

выдает ошибку Subscript of pointer to incomplete type 'struct student' подскажите пожалуйста


Ответы (1 шт):

Автор решения: Harry

Или просто пишите

struct student {
    char *name;
    char number_of_group[8];
    double score;
};

без typedef и передавайте как передаете, или дайте имя, например,

typedef struct student {
    char *name;
    char number_of_group[8];
    double score;
} Student_type;

и тогда передавайте

void console_output(Student_type *mephist , int count_of_elements){
→ Ссылка