Help.
TCHAR* b;
TCHAR* c=TEXT("qwerty");
I want to allocate memory and copy content of c
into b
.
Help.
TCHAR* b;
TCHAR* c=TEXT("qwerty");
I want to allocate memory and copy content of c
into b
.
I haven't worked in C++ for a while, but from memory the easiest is something like:
b = tcscpy(new TCHAR[tcslen(c) + 1], c);
The first step allocates the buffer (+1 for an extra TCHAR for the NUL delimiter); the second step copies the entire string into that new buffer; and finally assigns the result (the buffer) to b
.
Newer versions of the compiler will probably complain about not using the length-limited version of the copy routine (tcscpy_s
instead of tcscpy
).