From: naisbodo Newsgroups: comp.os.msdos.djgpp Subject: Re: loading an array of filenames with load_bitmap Date: 1 Dec 2000 19:34:07 GMT Organization: http://www.naisbodo.com/ Lines: 33 Message-ID: <908uff$n7o$5@bob.news.rcn.net> References: <908r2a$50c$1 AT jake DOT esu DOT edu> X-Trace: sjf0S2KrgjbTNkoY3RZgr0YvQoe1gO280OVFaOcxIww= X-Complaints-To: abuse AT rcn DOT com NNTP-Posting-Date: 1 Dec 2000 19:34:07 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Tom Hunt wrote: > I'm getting erratic behavior with this block of code. Sometimes the program > crashes in load_pcx. Sometimes it doesn't. > > #define NUM_IMAGES 3 > > char *names[NUM_IMAGES] = { > "GRASS.PCX", > "WATER.PCX", > "FOREST.PCX" > }; > ... > RGB *pal; > BITMAP *images[NUM_IMAGES]; > ... > for(int i=0; i { > images[i] = load_bitmap(names[i], pal); > } > > When it does crash, I get a page fault from within load_pcx. Would anyone > have an idea as to why this is happening? An error in memory allocation elsewhere could cause problems. What's the smallest *compilable* code segment you can post which exhibits this behavior? Nothing jumps out at me as wrong, here. To be pedantic, I'd suggest you declare names as const char *, but that is almost certainly not relevant to your problem. -- naisbodo AT enteract DOT com http://www.naisbodo.com/