|
|
|
|
Salut,
en attendant l'aide des personnes beaucoup, beaucoup plus experimentées en regardant ton code j'ai déjà remarqué des erreurs typedef struct image_N { int **tableau; }image_N Pour la déclaration des structures tu peux faire
struct image_N {
int **tableau;
};ou avec typedef typedef struct {
int **tableau;
}image_N;Il ne faut pas oublier le point-virgule à la fin
En ce qui concerne l'allocation de la mémoire il faut plutôt quelque chose de genre (struct image_N *) malloc( 5 * sizeof(struct image_N) )lami20j
|
Il faut allouer aussi chaque case des tableaux 1D
#include <stdlib.h>
struct matrix2d_t{
unsigned int nb_ligne;
unsigned int nb_colonne;
int **data;
};
matrix2d_t new_matrix2d(
unsigned int nb_lig,
unsigned int nb_col
){
matrix2d_t m;
unsigned int i;
m.data = (int **) malloc(nb_lig*sizeof(int *));
for(i=0;i<nb_lig;++i){
m.data[i] = (int *) malloc(nb_col * sizeof(int)); //alloc tableau 1d
}
m.nb_ligne = nb_lig;
m.nb_colonne = nb_col;
return m;
}
void del_matrix(matrix2d * m){
unsigned int i,nb_lig=m.nb_ligne;
for(i=0;i<nb_lig;++i){
free(m->data[i]);
}
free(m->data);
free(m);
}
ou quelque chose de ce goût là... Bonne chance
|
Bien vu ^^
~ iclic @ gauch,iclic, iclic @ droate, iclic, iclic et ya pas de bôg môsieu ! ~ |
Vouich, je crois que si l'on oublie d'inclure stdlib.h pour malloc on peut avoir des erreurs de ce type.
..et le...le...enfin, non parce c'est...ya...quand...bah tu sais là le... |
Résultats pour aide Structure en C
Résultats pour aide Structure en C
Résultats pour aide Structure en C
Résultats pour aide Structure en C
Résultats pour aide Structure en C
Résultats pour aide Structure en C