forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pgPrint question

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
JJPeerless



Joined: 20 Jun 2005
Posts: 82

PostPosted: Wed Jun 22, 2005 9:35 am    Post subject: pgPrint question Reply with quote

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
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Wed Jun 22, 2005 10:05 am    Post subject: Reply with quote

sprintf()?
Back to top
View user's profile Send private message
JJPeerless



Joined: 20 Jun 2005
Posts: 82

PostPosted: Wed Jun 22, 2005 10:23 am    Post subject: Reply with quote

well yea..i tried that..but then when i copmile it gets all angry

says

"undefined reference to sprintf"
Back to top
View user's profile Send private message
annerajb



Joined: 31 Mar 2005
Posts: 40

PostPosted: Wed Jun 22, 2005 10:36 am    Post subject: Reply with quote

could you post the code and with what are you compiling
Back to top
View user's profile Send private message MSN Messenger
JJPeerless



Joined: 20 Jun 2005
Posts: 82

PostPosted: Wed Jun 22, 2005 10:39 am    Post subject: Reply with quote

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'
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Wed Jun 22, 2005 12:49 pm    Post subject: Reply with quote

Link with libc (pass -lc on the linker command line)?
Back to top
View user's profile Send private message
MrSiir[S]



Joined: 14 Sep 2004
Posts: 32

PostPosted: Wed Jun 22, 2005 1:21 pm    Post subject: Reply with quote

use itoa(), if you don't have libc (ee-gcc), use custom function

itoa wrote:
char * itoa ( int value, char * buffer, int radix );


or, cutom ltoa function:
Code:
#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);
}
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group