Mail Archives: djgpp/1997/08/01/17:02:27
From: | Erik Max Francis <max AT alcyone DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: HELP! Unidentifiable bug in code
|
Date: | Sun, 27 Jul 1997 10:54:41 -0700
|
Organization: | Alcyone Systems
|
Lines: | 39
|
Message-ID: | <33DB8B61.701B64E6@alcyone.com>
|
References: | <5r5p46$bj0$1 AT excalibur DOT flash DOT net>
|
NNTP-Posting-Host: | newton.alcyone.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Joshua Eckstein wrote:
> I have written a small program, below, that I'm trying to have fade in
> and
> out several PCX images. It seems to do fine with only one, but two it
> just
> can't handle! What is wrong?
It in fact seems to be (though there may be other problems too) a simple
uninitialized pointer. My suggestion is you get a good book on ANSI C
programming and study the sections on pointers, arrays, and strings.
> COLOR *Pal1, *Pal2;//, *Pal3;
> PCXheader head1, head2;//, head3;
>
> LoadPCXinfo(file1, &head1, Pal1);
Pal1 and Pal2 are uninitialized pointers before they're being passed to
the LoadPCXInfo function, which attempts to fill out the color tables --
this will cause a crash.
What you need instead is
COLOR *pal1;
// ...
LoadPCXInfo(file1, &head1, &pal1);
LoadPCXInfo takes a COLOR *, which means that it needs a COLOR to actually
point to.
Using a source-level debugger would have easily revealed this problem.
--
Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
Alcyone Systems / web / http://www.alcyone.com/max/
San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W
\
"Love is not love which alters / when it alternation finds."
/ William Shakespeare, _Sonnets_, 116
- Raw text -