GP32 Gptextout


Siajj

Still Fresh
Joined
Apr 22, 2004
Messages
12
How can i use GpTextOut to output a variable, at the moment i am using:

GpTextOut(NULL, &gpDraw[nflip], count * TILESIZE, count2 * TILESIZE, count3, 0);

but all it is displaying is symbols.
 
You need to convert your int/float/whatever numerical variable to a string. You might do it with sprintf from <stdio.h>:

sprintf(count_string, "%i", count*tilesize);
GpTextOut(NULL, &gpDraw[nFlip], count_string, 0);
 
great, problem is i'm now getting an error:

warning: passing arg 1 of 'sprintf' makes pointer from integer without a cast

what does this error and how can i fix it???
 
Did you declare the string you're using? You need to declare it (big enough!) before using it with sprintf:

char count_string[100];
sprintf(count_string, "%i", count*tilesize);
GpTextOut(NULL, &gpDraw[nFlip], count_string, 0);
 
Back
Top