Mail Archives: djgpp/1999/04/03/00:01:10
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 -