Bonjour,

Je voudrais créer dynamiquement un tableau de 500 mots, chaque mot ayant une taille de 100 char.
En gros c'est un tableau à deux dimension (donc char**).
Ce que je faisai c'était:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
char **monTableau = NULL;
 
*monTableau = (char *) calloc(500, sizeof(char));
for(int i = 0; i < 100; i++)
monTableau[i] = (char *) calloc(100, sizeof(char));
Est ce correct?

Ensuite je veux ecrire des mots dans ce tableau donc je fais:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
char monMots[100] = "hello world!";
for(int i = 0; i < 500; i++)
memcpy( &monTableau[i] , monMots, 100 * sizeof(char));
Etes vous d'accord?

Je vous remercie