Hi, I am trying to convert an int to string.
char *msg; Itoa(5, msg);
also when using sprintf the code compiles but execution blocks at that line. Should sprintf work on the platform?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi, I am trying to convert an int to string.
char *msg; Itoa(5, msg);
also when using sprintf the code compiles but execution blocks at that line. Should sprintf work on the platform?
Hi Ray,
As your code stands, you will experience undefined behavior as you have not initialized char* msg. Try initializing the buffer:
char msg[5]; itoa(5, msg);
Please let me know if this solution works for you.
Thanks,
Taumer
Hi Taumer, thank you for your help.
with the above code the program doesn't compile because itoa() is not recognized. Itoa() as is stated here https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/148634 is also not recognized. stdlib.h is declared.
My apologies, Ray. This code should work for you after including stdlib.h:
char msg[5];
ltoa(5, msg);
The leading character is a lowercase "L" and not a capital "I".
Let me know if this works for you.
Thanks,
Taumer