From: Bowers Newsgroups: comp.os.msdos.djgpp Subject: segmentation errors Date: Thu, 22 May 1997 18:08:34 -0400 Organization: _ Lines: 58 Message-ID: <3384C3E2.730A@ntplx.net> Reply-To: bowrsfam AT ntplx DOT net NNTP-Posting-Host: p21-14.hftd.dialin.ntplx.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Greetings. Whenever I compile and run the following code, I always get segmentation errors. Can anyone help me fix the problem? Thank you VERY much, N Bowers void Load_Sprite(sprite_ptr sprite, pcx_image_ptr image, int number) { int offset = 0, work_offset; int curr_x_pos = 0, count1, y = 0, x = 0; int curr_y_pos = 0; char *work_sprite; (char *)work_sprite = (char *)sprite->frames[sprite->num_frames]; for(count1 = 0; count1 < number; count1++) { //sets up the offset by finding the current frame, then factoring the //one pixel boarder between each frame offset = SCREEN_WIDTH * (curr_y_pos * sprite->height) + (curr_x_pos * sprite->width) + curr_x_pos; work_offset = 0; for(y = 0; y < sprite->height; y++) { for(x = 0; x < sprite->width; x++) { work_sprite[work_offset + x] = image->buffer[offset + x]; } offset += SCREEN_WIDTH; work_offset += sprite->width; } sprite->num_frames++; curr_x_pos += 1; //increase curr pos if(curr_x_pos > 4) //maximum size of sprite will be 64 pixels { curr_y_pos += 1; curr_x_pos = 0; } if(curr_y_pos > 2) { return; } } }