I want to make a structure similar to course registration in C. For this, I used struct instead of the table.
STUDENT *createStudent(){
    return (STUDENT *) malloc(sizeof(STUDENT));
}
TEACHER *createTeacher(){
    return (TEACHER *) malloc(sizeof(TEACHER));
}
COURSE *createCourse(){
    return (COURSE *) malloc(sizeof(COURSE));
}
COURSEREGISTRATION *createCourseRegistration(){
    return (COURSEREGISTRATION *) malloc(sizeof(COURSEREGISTRATION));
}
I want to pass these functions to a variable with a function pointer. Like;
void *createNode(int choise){
    void (*fp[]) () = {createStudent, createTeacher, createCourse, createCourseRegistration};
    return (fp[choise] ());
}
I want to do malloc with func pointers and get an error in this function (main func);
STUDENT *studentHead = NULL;
void *temp = studentHead;
temp = createNode(0);//Zero for student
I dont understood func pointers clearly. What should I do? Where did I wrong? or can I use func pointer in this situation?
THX
EDIT: I solved the problem like this;
#define CREATESTUDENT 0
#define CREATETEACHER 1
#define CREATEDCOURSE 2
#define CREATECOURSEREGISTRATION 3
void createNode(void **temp, int choise){
    switch(choise){
        case CREATESTUDENT:
            *temp = (STUDENT *) malloc(sizeof(STUDENT));
            break;
        case CREATETEACHER :
            *temp = (TEACHER *) malloc(sizeof(TEACHER));
            break;
        case CREATEDCOURSE :
            *temp = (COURSE *) malloc(sizeof(COURSE));
            break;
        case CREATECOURSEREGISTRATION :
            *temp = (COURSEREGISTRATION *) malloc(sizeof(COURSEREGISTRATION ));
            break;
    }
}
and used call func;
STUDENT *temp = studentHead;
createNode(&temp, CREATESTUDENT);
 
     
     
    