I am a beginner in C and I'm trying to build my own student database. Here I'm trying to create a new student and I'm trying to understand how to use heap declarations. Here is code that I have using a stack declaration:
student* create_student(char *given_name, char *family_name, int age,
        char* gender, int *promotion)
{
    student s;
    s.given_name = given_name;
    s.family_name = family_name;
    s.age = age;
    strncpy(s.gender, gender, strlen(gender)+1);
    s.promotion = promotion;
    puts("---print inside create_student function---");
    print_student(s);
    puts("---end of print inside");
    return &s;
}
I understand that since we are using a stack here, the information is lost outside of the function, however I'm a bit confused as to how I can "convert" this into a heap.
[I have studied C++ before so I tried with something like student *s = new student]
So my question is, how would I convert this into a heap declaration so as to retain the info outside of the function?
 
    