Skip to main content
idrissmc
Associate III
December 10, 2019
Question

garbage value with sprintf

  • December 10, 2019
  • 2 replies
  • 1363 views

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

    This topic has been closed for replies.

    2 replies

    idrissmc
    idrissmcAuthor
    Associate III
    December 10, 2019

    It's ok, I found it :D

    Piranha
    Principal III
    December 10, 2019

    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().