www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/04/13:57:54

Sender: nate AT cartsys DOT com
Message-ID: <35C739C4.D87B9572@cartsys.com>
Date: Tue, 04 Aug 1998 09:41:40 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
MIME-Version: 1.0
To: "Xee'Gh" <pekkaka AT dlc DOT fi>
CC: djgpp AT delorie DOT com
Subject: Re: Its me Please ...
References: <01bdbe08$aeac86c0$LocalHost AT default>

Xee'Gh wrote:
> 
> Hi, I just started to make new program with graphics.I know that i should
> use allegro but i just have this kind of fever to make this working. I
> wrote a code that would
> unpack pcx files, but i only get on freaky error.
> 
> p.c:77 warning: comparison is always 0 due to limited data type.
> 
> i cut& paste the code what the error message refers to. Please HELP me.
> And if you know that this code has faults please tell me how would you do
> it.
> or if theres just some minor faults please tell me how to fix them.
> 
> thanks in advance.
> 
> write to pekkaka AT dlc DOT fi with possible fixes.
> 
> ''Code'''
> 
> int UnpackPCX(FILE *fh, char *buffer, int width,  int Height)
> {
> char palette[768];
> char *wbuf, *wptr, c, l;

[snipped]

>       if (c > 191)                /* This is the error point */ <77>
>        {
[snipped more]

You declare `c' as `char'.  Here, a `char' is an 8-bit value, signed by
default.  Thus, its range is from -128 to 127.  Clearly, if `c' can
never exceed 127, it will never be greater than 191.

You probably want to declare `c' as `int'; that is standard procedure
for character variables.  It has the added advantage that you will be
able to correctly handle the EOF value, which is outside the range of
even an `unsigned char'.
-- 

Nate Eldredge
nate AT cartsys DOT com


- Raw text -


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