Skip to main content
Visitor II
August 12, 2022
Question

Newline not working in string

  • August 12, 2022
  • 3 replies
  • 1083 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

    Graduate II
    August 12, 2022

    Use the proper escape character, ie \n

    Graduate II
    August 12, 2022

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

    Super User
    August 12, 2022

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