C言語なら俺に聞け(入門編)Part 118
■ このスレッドは過去ログ倉庫に格納されています
0404デフォルトの名無しさん
2013/08/20(火) NY:AN:NY.ANint height,width;
int i,j;
u_char*** src;
// src[h][w][3] を確保する
src = (u_char***)malloc(sizeof(u_char**) * height);
for(i = 0; i < height; ++i){
src[i] = (u_char**)malloc(sizeof(u_char*) * width);
}
for(i = 0; i < height; ++i){
for(j = 0; j < width; ++j){
src[i][j] = (u_char*)malloc(sizeof(u_char) * 3); //ピクセル毎のバイト数=3
if(src[i][j]==NULL){ return -1; }
}
}
三次元構造を作ってみたのですがこれのアクセスはsrc[h][w][3]で大丈夫ですか?
■ このスレッドは過去ログ倉庫に格納されています