以下の関数があるとしましょう。
void function createBands(boolean option) {
int i, j;
int ***bands = (int ***)malloc((SIZE + 1) * sizeof(int **));
for (i = 0; i < SIZE; i++) {
bands[i] = (int **)malloc(HEIGHT * sizeof(int *));
for (j = 0; j < HEIGHT; j++)
bands[i][j] = (int *)malloc(WIDTH * sizeof(int));
}
iterator *it =
createIterator(params); // do not be confused it is a structure with
// methods andaeribute just like Iterator class in
// java . Methods are poniters to functions.
repare_array(bands[Size], it);
}
void prepare_array(int **band, iterator *it) { read_array(band, it); }
read_array(int **band, iterator *it) {
for (int i = 0; i < Height; i++)
band[i] = (int *)it->next();
}
// Now in Iterator.c I have the iterator structure with the methods etc I will
// write just some line form iterator.
void *next() {
byte *b =
a function that reads bytes form a file and returns byte * CORECTLY !!!;
return b == NULL ? NULL : bytetoT(b);
// this function make void form byte conversion but it doesnt work so I make
// only a cast in read_aray as you see. SUppose just return b wich is byte(i
// know in C isn't any byte but I redeclared all the types to be JAVA.)
}
質問は、バンドをどこに割り当てる必要があるかです。この状況では、関数スコープで値が表示されるため、関数によって返される 1D ベクトルは問題ありません。しかし、array[i] に戻ると、割り当てられていない 3dVector を取得しました。データ形式 b で、bands[size][i][j] を受け取る必要があります。b では、データが良好である場合、バンドが null になります。これまでに行ったことは、**band を割り当てる read_array を呼び出す前に、準備配列で別の割り当てを行い、結果が得られましたが、自信がありません。混乱させて申し訳ありません!そして、すべてのコメントは私にとって良いものです。多分私がしたことは大丈夫です私は知りません!. 私はCIに慣れていないだけで、ポインターを長い間使用していません。