say i have a int variable named score (which keeps track of your score in a game...)
and on the screen i want to print "Score: 234"  where 234 is the itneger stored in score..
how do i go about sending something like pgPrint(x,y,color,"Score: " + score)
i cant figure it out.. thanks
			
			
									
									
						pgPrint question
- 
				JJPeerless
- Posts: 82
- Joined: Mon Jun 20, 2005 3:32 am
- 
				JJPeerless
- Posts: 82
- Joined: Mon Jun 20, 2005 3:32 am
im using psp-gcc to compile everything..
ive added these includes
#include <stdlib.h>
#include <stdio.h>
and im using it as follows:
char buffer[20];
sprintf(buffer,"%i",score);
	
pgPrint(54,3,0xffff,"Score");
pgPrint(56,7,0xffff, buffer);
if "compiles" fine with psp-gcc
but the error comes in my main.o file
undefined reference to 'sprintf'
			
			
									
									
						ive added these includes
#include <stdlib.h>
#include <stdio.h>
and im using it as follows:
char buffer[20];
sprintf(buffer,"%i",score);
pgPrint(54,3,0xffff,"Score");
pgPrint(56,7,0xffff, buffer);
if "compiles" fine with psp-gcc
but the error comes in my main.o file
undefined reference to 'sprintf'
use itoa(), if you don't have libc (ee-gcc), use custom function
			
			
									
									
						or, cutom ltoa function:itoa wrote:char * itoa ( int value, char * buffer, int radix );
Code: Select all
#define MAX_LENGTH 32+1
char* _ltoa(char* buf, long i, int base)
{
    char reverse[MAX_LENGTH+1];	// plus one for the null
    char* s;
    char sign = i < 0;
    i = labs(i);
    reverse[MAX_LENGTH] = 0;
    s = reverse+MAX_LENGTH;
    do {
        *--s = "0123456789abcdefghijklmnopqrstuvwxyz"[i % base];
        i /= base;
    } while (i);
    if (sign) *--s = '-';
    return strcpy(buf, s);
}