Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 int convert(string *ttab){ int i=0; string s; while (ttab[i]!=NULL){ strcpy(s,ttab[i]); printf("%s",s); i++; } return 0; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 int convert(string *ttab){ int i=0; string s; while (ttab[i]!=NULL){ strcpy(s,ttab[i]); printf("%s",s); i++; } return 0; }
ton code c'est n'importe quoi.
ce que tu déclares n'a rien d'un tableau de pointeur c'est un pointeur sur string qui n'existe pas en C donc forcément d'une définition à toi.
il faut passer le nombre d'élément de ton tableau à la fonction
Il n' y a pas trente-six façons de connaître la taille d'un tableau passé en paramètre.
Soit tu passes explicitement la taille dans un autre paramètre,
Soit tu utilises une valeur sentinelle, mais dans ce cas la fonction ne doit pas tenter d'agrandir le tableau, sauf l'agrandissement maximal par la fonction est garanti (par exemple, strcat() n'agrandit jamais de plus que la longueur de la seconde chaîne).
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.
"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone. -- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
Bhh la question c’est :
puis je tester sur le NULL ?
while (ttab[i]!=NULL)
Non, car ton type string n'est pas un type pointeur : Il ne peut être NULL.
Si c'était un type pointeur, les explications d'hegros s'appliqueraient.
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.
"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone. -- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
"The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
"If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow
FAQ-Python FAQ-C FAQ-C++
+
C'est parce qu'il commence par "str", c'est ça ?
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.
"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone. -- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
"The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
"If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow
FAQ-Python FAQ-C FAQ-C++
+
Sans doute.
Emmanuel l'a souvent dit, tout ce qui commence par "str" suivi d'une minuscule fait partie des identificateurs réservés.
http://emmanuel-delahaye.developpez....htm#id_reserve
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.
"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone. -- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
J'aimerais bien qu'on l'affiche cette norme en post-it le problème est qu'à priori la C99 n'est pas gratuite.
http://www.open-std.org/jtc1/sc22/wg...docs/n1124.pdf
Thierry7.26.11 String handling <string.h>
1 Function names that begin with str, mem, or wcs and a lowercase letter may be added to the declarations in the <string.h> header.
"The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
"If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow
FAQ-Python FAQ-C FAQ-C++
+
ce n'est pas une fonction qui commence par str dans le cas du PO...
dot-_-net c'est quoi ton compilateur ?
"The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
"If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow
FAQ-Python FAQ-C FAQ-C++
+
"The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
"If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow
FAQ-Python FAQ-C FAQ-C++
+
Partager