Date: Thu, 10 Jul 1997 09:58:48 -0400 (EDT) From: "Art S. Kagel" To: levity AT minn DOT net Cc: djgpp AT delorie DOT com Subject: Re: General protection fault because of modulus? In-Reply-To: <01bc8c6e$c991d480$3564a8c0@Kelly.ns1.uswest.net> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On 9 Jul 1997 levity AT minn DOT net wrote: > I am writing a program for the purpous of learing how to read binary files. > I am using the modulus fo counting coloms for the out put but every time I > add the code to do this the program runs and then ends with a general > protection fault. Any ideas why I am getting the general protection fault? > Also for future reference should I include my code in a different way when > posting these questions? > > #include > #include > #include ".\bmphead.h" > > > > int main(int argc, char *argv[]) > { > > long pal[3][256]; > pal[3][i] = palette.Pad; ^^^ Here is your problem, pal is defined as long pal[3][256], the first dimension has only three elements, numbered 0, 1, & 2 there is no pal[3]... > (void)printf("%ld,%ld,%ld,%ld |\n", pal[0][i], pal[1][i], pal[2][i], > pal[3][i]); ^^^ -- No pal[3]... > } > else > (void)printf("%ld,%ld,%ld,%ld |", pal[0][i], pal[1][i], pal[2][i], > pal[3][i]); ^^^ -- No pal[3]... > Art S. Kagel, kagel AT bloomberg DOT com