delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/10/10:00:41

Date: Thu, 10 Jul 1997 09:58:48 -0400 (EDT)
From: "Art S. Kagel" <kagel AT ns1 DOT bloomberg DOT com>
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: <Pine.D-G.3.91.970710095630.25594C-100000@dg1>
Mime-Version: 1.0

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	<stdio.h>
> #include	<stdlib.h>
> #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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019