How a CString variable can be assigned to another CString variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How a CString variable can be assigned to another CString variable

30th Dec 2020, 8:15 AM
Baluch
1 Answer
+ 4
You can use strcpy() to copy the characters, but you need to make sure the second C-string has the necessary size: https://en.cppreference.com/w/c/string/byte/strcpy On a sidenote, C23 might introduce strdup(), which duplicates a string while also taking care of the allocation (dynamically): https://en.cppreference.com/w/c/string/byte/strdup
30th Dec 2020, 8:24 AM
Shadow
Shadow - avatar