Bonjour,

J'essaie de réecrire une fonction de tri (ici, c'est le tri selection) avec la meme entete que celle du qsort.

Seulement voilà, je me retrouve confronté a des warning, et pas moyen de les enlevés

Voici le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
 
void tri(void *tableau, size_t nb_elements, size_t taille_elements, int(*comp)(const void *, const void *))
{
     int max, i;
     void *x = (void *)malloc(taille_elements);
 
     while(nb_elements>1)
     {
          max=0;
 
          for(i=1;i<nb_elements;i++)
               if(comp(tableau+(taille_elements*i),tableau+(taille_elements*max))>0) max=i;
 
          memcpy(x, tableau+(taille_elements*max), taille_elements);
          memcpy(tableau+(taille_elements*max), tableau+(taille_elements*(nb_elements-1)), taille_elements);
          memcpy(tableau+(taille_elements*(nb_elements-1)), x, taille_elements);
 
         nb_elements--;
     }
 
     free(x);
}
Voici les warnings générés :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
Selection.c:16: attention : pointer of type «void *» used in arithmetic
Selection.c:16: attention : pointer of type «void *» used in arithmetic
Selection.c:18: attention : pointer of type «void *» used in arithmetic
Selection.c:19: attention : pointer of type «void *» used in arithmetic
Selection.c:19: attention : pointer of type «void *» used in arithmetic
Selection.c:20: attention : pointer of type «void *» used in arithmetic
Si quelqu'un pouvais m'aider à en résoudre ca serait sympathique.

Merci d'avance.