Bug with sprintf()

Started by
2 comments, last by Daivuk 19 years, 2 months ago
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
Advertisement
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?
Quote:Original post by Daivuk
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?
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).
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 ;)

This topic is closed to new replies.

Advertisement