Bonjour!
Je voudrais allouer une matrice de ce type dans le tas :
ma_matrice[indice_entier1][indice_entier3][indice_entier3] = flottant
Je l'ai déclarée et initialisée comme ceci mais je ne suis pas sûr du tout de moi notamment pour les paramètres des malloc...
Est-ce que quelqu'un pourrait me dire si c'est cohérent ou pas?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 float ***ma_matrice ma_matrice = (float ***)malloc(nb_indices_entier1 * sizeof(int)); for(i = 0; i < nb_indices_entier1; i++){ ma_matrice[i] = (float **)malloc(nb_indices_entier2 * sizeof(int)); for(j = 0; j < nb_indices_entier2; j++){ ma_matrice[i][j] = (float *)malloc(nb_indices_entiers3 * sizeof(float)); } }
Merci!
Partager