Skip to main content
Associate
May 6, 2024
Solved

Resize string variable

  • May 6, 2024
  • 3 replies
  • 1160 views

Hi i have this code:

 

char string[6]="Hello";

char string1[6]="World";

 

touchgfx::Unicode::UnicodeChar dst[6];

touchgfx::Unicode::UnicodeChar dst1[6];

touchgfx::Unicode::UnicodeChar txtAreaBuffer1[100];

 

Unicode::strncpy(dst, string, 6);

Unicode::strncpy(dst1, string1, 6);

 

Unicode::snprintf(txtAreaBuffer1, 100, "%s", dst, dst1);

 

Unicode::strncpy(txtAreaBuffer, txtAreaBuffer1, 100);

txtArea.invalidate();

 

Why i have output only Hello instead HelloWorld?

 

This topic has been closed for replies.
Best answer by Pavel A.

Unicode::snprintf(txtAreaBuffer1, 100, "%s %s", dst, dst1);

3 replies

Pavel A.
Pavel A.Best answer
Super User
May 6, 2024

Unicode::snprintf(txtAreaBuffer1, 100, "%s %s", dst, dst1);

Tesla DeLorean
Guru
May 6, 2024

>>Why i have output only Hello instead HelloWorld?

You format a single string, but pass two parameters

Unicode::snprintf(txtAreaBuffer1, 100, "%s%s", dst, dst1);

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
SchamannAuthor
Associate
May 6, 2024

Ofcourse, my mistake...