il debug dice:
il programma ha causato una violazione di accesso (errore di segmentazione).


codice:
        int coordx = buf[18]+buf[19]*256; 
        int coordy = buf[22]+buf[23]*256; 

               b = fread( buf, 1, lbuffer, file); 
               printf("file caricato nel buffer...\n"); 
                
               long x,y,z=0; 
               //caricamento in array bidimensionale... 
               unsigned char mappa[coordx][coordy][4];    
               printf("mappa a due dimensioni creata...\n"); 
               for(y=0; y < coordy ;y++){ 
               for(x=0;x < coordx;x++){  
                    
                         mappa[x][y][0] = buf[z]; 
                         mappa[x][y][1] = buf[(z+1)]; 
                         mappa[x][y][2] = buf[(z+2)];                          
                         z=z+3; 
               }} 
               printf("byte immagazzinati nella mappa: %d \n",z); 
                  
                  
               for(y=0; y < coordy ;y++){ 
               for(x=0;x < coordx;x++){  
                          
                             unsigned char *wbuf; 
                             wbuf = new unsigned char [4]; 
                             wbuf[0]= mappa[x][y][0]; 
                             wbuf[1]= mappa[x][y][1]; 
                             wbuf[2]= mappa[x][y][2]; 
                             fwrite( wbuf, 1, 3, f_out); 
               }}
il programma si ferma qui:
unsigned char mappa[coordx][coordy][4];


grazie in anticipo