Skip to main content
VEnes.1
Visitor II
August 12, 2022
Question

Newline not working in string

  • August 12, 2022
  • 3 replies
  • 1117 views

I use stm32cubeIDE

my code:

sprintf( mesaj, "xaccl = %3.3f /n ", xaccl );
HAL_UART_Transmit( &huart6, mesaj, sizeof(mesaj), HAL_MAX_DELAY );

how I can fix /n terminal problem?

thanks for answers

0693W00000QNYriQAH.bmp

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
August 12, 2022

Use the proper escape character, ie \n

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
August 12, 2022

Might also point out that sprintf returns the length of the generated string, and sizeof() isn't suitable for strings.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Bob S
Super User
August 12, 2022

And use snprintf() instead of sprintf(). Friends don't let friends use sprintf().