J'ai des problèmes avec la notation de pointeur/tableau utilisée. J'ai deux listes et je suis en train de les trier, puis j'essaie de les afficher. J'ai eu 3 commentaires dans mon code ci-dessous sur ce que sont les déclarations et pourquoi. Mon code ressemble:Aide avec des pointeurs en C en utilisant qsort, bsearch
int Compare(const void *a, const void *b);
void SortStudents(char *studentList[], size_t studentCount)
{
qsort(studentList, studentCount, sizeof(studentList[0]), Compare);
}
int Compare(const void *a, const void *b)
{
return (strcmp(*(char **)a, *(char **)b));
}
/*Determines which registrants did not attend the first meeting by searching for registrants
that are not in attendees set. */
void DisplayClassStatus(
const char *registrants[], size_t registrantCount,
const char *attendees[], size_t attendeeCount)
{
char **missedFirstMeeting; // not sure if this is the right declaration
char *start, *end;
// not sure if this is right with the &attendees and registrants for the bsearch()
missedFirstMeeting = bsearch(&attendees, registrants, attendeeCount,
sizeof(attendees[0]), Compare);
printf("Missed First Meeting: \n");
//not sure if this the way to traverse through the array using pointers to display
for (start = missedFirstMeeting, end = &missedFirstMeeting[registrantCount-1]; start < end; ++start) {
printf("%s", *start);
}
}
S'il s'agit de devoirs, ajoutez l'étiquette 'devoirs '. –