#include #include #include /*La fonction map permet de parcourir le tableau. */ void map(void *base,size_t n ,size_t size_elem,void(*f)(void *)){ int i; char *ptr = (char*)base; for(i=0;i un pointeur sur un tableau de caractère } int cmp_string (const void* a, const void* b) { const char* *ia = (const char* *)a; const char* *ib = (const char* *)b; return strcmp(*ia, *ib); } int main(){ int t1[10]={12,-7,1,-16,3,19,7,1,5,0}; char * t2[]={"chou","joujou","bijou","genou", "caillou","hibou","pou"}; map(t1,10,sizeof(int),print_int); printf("\n"); map(t2,7,sizeof(char*),print_string); printf("\n"); qsort(t1,10,sizeof(int),cmp_int); map(t1,10,sizeof(int),print_int); printf("\n"); qsort(t2,7,sizeof(char *),cmp_string); map(t2,7,sizeof(char*),print_string); printf("\n"); }