cancel
Showing results for 
Search instead for 
Did you mean: 

garbage value with sprintf

idrissmc
Associate III

hi everyone,

Can someone tell me if sprintf is ok in Keil? Tera term prints garbage value.

2 days ago I tried sprintf and it didn't work, I tried a simple declaration of a string and it worked.

what's the problem?

0690X00000AtWZDQA3.png

0690X00000AtWZSQA3.png

0690X00000AtWZXQA3.png

2 REPLIES 2
idrissmc
Associate III

It's ok, I found it :D

Piranha
Chief II

You must provide an array to it, not uninitialized pointer.

Also take a note that sprintf() is unsafe, because it isn't aware of output buffer size. Better use snprintf().