# Bug with sprintf()

## Recommended Posts

Hi there, I'm trying to code for the GBA (game boy advance) to practice my seft to core coding :P But I have a bug, sprintf dont work. It return that he write 0 caracter.. What I did in my main() :
u16 Temp = 1230;
char strText[31] = "";
s16 Result = sprintf(strText, "Testing %i", Temp );
if (Result < 0) OutputText("Error");
if (Result == 0) OutputText("0 Caracter writed");
OutputText(strText);


My function OutputText(char*) work perfectly, because I can read : "0 Caracter writed" But I cant see "Testing" on the final OutputText because sprintf just dont work.. What can be the prob? Something to do with the gba? Because I see a guy using sprintf in his gba programme, and it work for him. Thanks

##### Share on other sites
hum... I declare this in the main :

u16 Map[512*512] = {0};

And if I comment it, sprintf work :S
Some ram trouble in the gba?

##### Share on other sites
Quote:
 Original post by Daivukhum... I declare this in the main :u16 Map[512*512] = {0};And if I comment it, sprintf work :SSome ram trouble in the gba?
Let's see, 512*512*2 = 512 kB. There's just no way that'll fit in 32 kB of IWRAM (or even in 256 kB of EWRAM, if you have a weird linker script).

##### Share on other sites
ok, thats why.
I put my map in const in a .h
Like this its include in the ROM file, that can be 9 Mb ;)