To define two functions with the same name in C constitutes a sin. In your case, what you really want is probably one of two things. Either define two functions:
compare_by_first_name
compare_by_last_name
with the obvious functionality, or, alternatively, one function: compare(char * name1, char * name2)
which is then called as such:
compare (student1->name, student2->name);
compare (student1->lastname, student2->lastname);