Salut,
j'ai des conflits de types mais je n'arrive pas à comprendre pourquoi...
voici mes erreurs:
ma source :mapString.h:7:3: erreur: conflicting types for ‘arrayString’
mapString.h:7:3: note: previous declaration of ‘arrayString’ was here
mapString.h:13:3: erreur: conflicting types for ‘mapString’
mapString.h:13:3: note: previous declaration of ‘mapString’ was here
mapString.h:15:6: erreur: conflicting types for ‘mapString_display’
mapString.h:15:6: note: previous declaration of ‘mapString_display’ was here
mapString.h:17:13: erreur: conflicting types for ‘mapString_create’
mapString.h:17:13: note: previous declaration of ‘mapString_create’ was here
mapString.h:19:6: erreur: conflicting types for ‘mapString_addArray’
mapString.h:19:6: note: previous declaration of ‘mapString_addArray’ was here
mapString.h:21:6: erreur: conflicting types for ‘mapString_destroy’
mapString.h:21:6: note: previous declaration of ‘mapString_destroy’ was here
mapString.h:23:5: erreur: conflicting types for ‘mapString_isset’
mapString.h:23:5: note: previous declaration of ‘mapString_isset’ was here
mon header :
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 #include "mapString.h" void mapString_display(mapString myMap) { int i; i=0; for (i=0;i<(myMap.size);i++) { fprintf(stdout, "%s and %s\n",myMap.association[i].key, myMap.association[i].value); } } mapString* mapString_create(int nb) /*nb Maximum size of the map*/ { mapString *toReturn=malloc(sizeof(mapString)); toReturn->size=0; toReturn->association=malloc(nb*sizeof(arrayString)); return toReturn; } void mapString_addArray(mapString * myMap, char* myKey, char* myValue) { int i; bool found; i=0; found=false; while ((!found) && (i<myMap->size)) { if (strcmp (myMap->association[i].key,myKey) == 0) { strcpy (myMap->association[i].key,myKey); strcpy (myMap->association[i].value,myValue); found=true; } i++; } if(!found) { strcpy (myMap->association[myMap->size].key,myKey); strcpy (myMap->association[myMap->size].value,myValue); myMap->size++; } } void mapString_destroy(mapString * myMap) { free(myMap->association); free(myMap); } int mapString_isset(mapString myMap,char* key) { int i; i=0; for(i=0; i<myMap.size;i++) { if(strcmp (myMap.association[i].key,key)==0) {return i; } } return -1; }
Voila, si vous pouvez m'aider..
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 #include <stdbool.h> typedef struct { char key[200]; char value[200]; } arrayString; typedef struct { arrayString* association; int size; } mapString; void mapString_display(mapString myMap); mapString * mapString_create(int nb); void mapString_addArray(mapString * myMap, char* myKey, char* myValue); void mapString_destroy(mapString * myMap); int mapString_isset(mapString myMap,char* key);
Et au passage quelqu'un pourrai me dire qi il y a un moyen pour eviter que j'ai a definir mes char* comme ça key[200] ?
Partager