0

how are you? i am trying to add to a path a variable. I created a variable that inside it has the name of the user of windows. So, i want to add that variable to the path.

    TCHAR username[UNLEN + 1];
DWORD usernamel_len = UNLEN + 1;

GetUserName((TCHAR*)username, &usernamel_len);

const char* path = "C:\\Users\\" + username  +"\\Desktop\\app\\folder";
LaCkzzz
  • 11
  • 3
  • My strong recommendation is you abandon `TCHAR` completely. If you choose to use it you must use it consistently or you will have nothing but trouble if you are actually using it for what it was intended for. – Retired Ninja May 01 '20 at 20:32
  • To put a finer point on what Ninja said, how it is being used in this code is not how it was intended for. – Eljay May 01 '20 at 21:19

1 Answers1

0

Use the C++ power.

#include <string>

const auto path = "C:\\Users\\"s + username + "\\Desktop\\app\\folder";
273K
  • 29,503
  • 10
  • 41
  • 64