Are you defining your function in a different file... or after you define main()? If it is defined elsewhere and you do not have a function prototype before main(), then you will get the warnings and linker error.
I did the following all in a single file (main.c) and it compiled without any issues.
typedef struct stud_type_ {
int matricnum;
char name[20];
struct stud_type_ *next_student;
} stud_type;
typedef struct sort_List {
stud_type *cur;
struct sort_List *next;
} sortList;
stud_type listofStudents; // Assume that it is not NULL
sortList * sortbyName() {
sortList *sList;
//sort algorithm here
return sList;
}
int main() {
sortList * curTEST = sortbyName();
while (curTEST!=NULL) {
printf("Name: %s\n", curTEST->cur->name);
curTEST = curTEST->next;
}
return 0;
}
Note that I only made two changes to your file. I changed your structure for sortList when defining the pointer to next. I changed it from struct sortList *next
to struct sort_List *next
. And I defined and initialized curTEST as sortList * curTEST = sortbyName()
.