| View previous topic :: View next topic |
| Author |
Message |
Acegikmo
Joined: 19 Jul 2008 Posts: 15
|
Posted: Mon Jul 28, 2008 5:40 am Post subject: How do I write the text in printTextScreen(); ? |
|
|
Another question how to write something :)
extern void printTextScreen(int x, int y, const char* text, u32 color);
How do I write the text?
I want it to show the value of this variable:
double dist;
But this doesn't work:
printTextScreen(32, 32, dist, 0xFFFFFFFF); |
|
| Back to top |
|
 |
pspZorba
Joined: 22 Sep 2007 Posts: 156 Location: NY
|
Posted: Mon Jul 28, 2008 5:54 am Post subject: |
|
|
never used this function but from its prototype:
char buffer[42];
sprintf( buffer,"%lf", dist);
printTextScreen(32, 32, buffer, 0xFFFFFFFF); _________________ --pspZorba--
NO to K1.5 ! |
|
| Back to top |
|
 |
Acegikmo
Joined: 19 Jul 2008 Posts: 15
|
Posted: Mon Jul 28, 2008 6:16 am Post subject: |
|
|
Works great :)
But could you explain what this line does?
sprintf( buffer,"%lf", dist);
I mean, what's "%lf" ? |
|
| Back to top |
|
 |
pspZorba
Joined: 22 Sep 2007 Posts: 156 Location: NY
|
Posted: Mon Jul 28, 2008 6:42 am Post subject: |
|
|
your printTextScreen needs a char * .
you want to print a double (dist, so you have to translate the double into a string. sprintf does the job.
sprintf needs a string ( buffer) that will contain the string, the variable you want to translate (dist) and the format => "%lf"
lt means the variable (dist) is a double.
If you wanted to transform an integer you would have set "%d". _________________ --pspZorba--
NO to K1.5 ! |
|
| Back to top |
|
 |
Acegikmo
Joined: 19 Jul 2008 Posts: 15
|
Posted: Mon Jul 28, 2008 6:53 am Post subject: |
|
|
| What about float variables? |
|
| Back to top |
|
 |
hibbyware
Joined: 28 Mar 2007 Posts: 78
|
|
| Back to top |
|
 |
WosRet
Joined: 23 Apr 2008 Posts: 15 Location: Confoederatio Helveticae
|
|
| Back to top |
|
 |
Acegikmo
Joined: 19 Jul 2008 Posts: 15
|
Posted: Mon Jul 28, 2008 8:23 am Post subject: |
|
|
| Thanks :) |
|
| Back to top |
|
 |
|