delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/03/00:01:10

To: djgpp AT delorie DOT com
Subject: Re: Here's the code for getpixel problem
References: <63gN2.58$ix1 DOT 35635 AT newse3 DOT tampabay DOT rr DOT com>
From: Michael Bukin <M DOT A DOT Bukin AT inp DOT nsk DOT su>
Date: 03 Apr 1999 11:50:38 +0700
In-Reply-To: jayjohnson@rocketmail.com's message of "Sat, 03 Apr 1999 03:38:42 GMT"
Message-ID: <20aewqe28x.fsf@Sky.inp.nsk.su>
Lines: 26
X-Mailer: Gnus v5.5/Emacs 19.34
Reply-To: djgpp AT delorie DOT com

jayjohnson AT rocketmail DOT com (Jay Johnson) writes:

> The program compiles and runs but it does not produce the 
> expected results.

> float temp;
> ...
> putpixel(buffer, 0, 0, 6);     /*put a pixel on 0,0 and color it 6(white)*/
> temp=getpixel(buffer, 0, 0);   /*read the 0,0 pixel and store in temp*/
> 		
> sprintf(textbuf, "getpixel:%d", temp); /*put the temp value into a string*/

You are using %d format specifier with floating point value.  Either
declare temp as integer, or change format specifier to floating
point, for example %f or %g.  Also use -Wall switch of gcc, then
compiler will report some of your mistakes.

c:/temp> gcc -O -Wall -c test.c

test.c: In function `main':
test.c:8: warning: int format, double arg (arg 3)

BTW, you can use textprintf instead of sprintf+textout.

-- 
Michael Bukin

- Raw text -


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