• Advertisement
Sign in to follow this  

access violation (segmentation fault)*unsolved*

This topic is 4919 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

it says the afformentioned error was found in my program in this line and i dont exacly know what it means array[3]=(BITMAP *)datafile[river_ver].dat,datafile [mountain].dat,datafile[plains].dat; [Edited by - raptorstrike on September 2, 2004 9:51:36 PM]

Share this post

Link to post
Share on other sites
In general, a segmentation fault (or/and a segmentation fault) arises when some part of memory is accessed which has not been allocated previously.

Without more information on the context (which compiler are you using, which operating system, which development api etc...) it's hard to find the precise answer to your question, but if I should guess, I'd think it's one of the following:

- "array" has not been sized correctly, so maybe you allocated array = new whatevertype[3]; instead of new whatevertype[4];
- same is true for datafile: size too small?

Actually, I don't quite understand the line... Which language is this?!

or should it read:

array[3] = {(BITMAP *) datafile[river_ver].dat, datafile[mountain].dat, datafile[plains].dat}; ??

But even that wouldn't make any sense...
Sorry for the somewhat unhelpful try of assistance; maybe you can provide some more context and I (or someone better suited) can help you further...

Share this post

Link to post
Share on other sites
i dose look kind of wierd cause im using allegro this is c++ but it is a genral debug error (not alleg. stacific so i posted it here

#include "main.h"
#include "allegro.h"
#include "tile.h"

int main(int argc, char *argv[])
tile the_tile;
DATAFILE *datafile;
BITMAP * array[3];
(BITMAP *) datafile[river_ver].dat;
int identifire;
int array2[2][3];
int x;
int y;
array2[2][3]= 1,2,0,2,1,0;
(BITMAP *) datafile[mountain].dat;
(BITMAP *) datafile[plains].dat;
array[3]= (BITMAP *) datafile[river_ver].dat,datafile[mountain].dat,datafile[plains].dat;
char buf[256];

if (set_gfx_mode(GFX_AUTODETECT_WINDOWED , 320, 200, 0, 0) != 0) {
set_gfx_mode(GFX_TEXT , 0, 0, 0, 0);
allegro_message("Unable to set any graphic mode\n%s\n", allegro_error);
return 1;
/* load the datafile into memory */
replace_filename(buf, argv[0], "datafile.dat", sizeof(buf));
datafile = load_datafile(buf);
if (!datafile) {
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
allegro_message("Error loading %s!\n", buf);
return 1;

int templat[2][3]={1,0,1,2,2,0};
set_palette((RGB *)datafile[main_palette].dat);

/* aha, set a palette and let Allegro convert colors when blitting */

/* display the bitmap from the datafile */
textout(screen, font, "This is the bitmap:", 32, 16, makecol(255, 0, 255));

/* and use the font from the datafile */
// textout(screen, datafile[BIG_FONT].dat, "And this is a big font!", 32, 128,
// makecol(0, 255, 0));


/* unload the datafile when we are finished with it */

return 0;


im just declaring an array of BITMAPS via a seprate data file datafile.dat and i am specifying what spacific map [river_ver] in a large set of bitmaps

EDIT: by the way my compiler (dev-cpp dosnt like those {} around the array so thats why there not there

Share this post

Link to post
Share on other sites
Okay, I think the problem is with your array declaration:

BITMAP *array[3];

declares an array of pointers... Valid from




so, if you'd like to access the third entry, write

array[2] = ...

or increase the size.


[Edited by - Beren77 on September 3, 2004 7:15:30 AM]

Share this post

Link to post
Share on other sites
well i fixed my function (that did go of the base of 1-3) so i did prevent a future error but this error persists its in this line

array[0]=(BITMAP *) datafile[river_ver].dat;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement