Timeline for answer to Assigning const char* to char* by bolov
Current License: CC BY-SA 4.0
Post Revisions
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 10, 2019 at 9:00 | history | edited | bolov | CC BY-SA 4.0 |
deleted 11 characters in body
|
| Dec 10, 2019 at 8:54 | history | edited | bolov | CC BY-SA 4.0 |
added 339 characters in body
|
| Dec 10, 2019 at 8:53 | comment | added | bolov | @keanehui1 no. You allocate mem for just 1 char | |
| Dec 10, 2019 at 8:52 | comment | added | keanehui1 |
if I do this, and it works, is it the same as your solution? char* str0 = new char; const char* str1 = "abc"; strcpy(str0, str1);
|
|
| Dec 10, 2019 at 8:42 | history | edited | bolov | CC BY-SA 4.0 |
added 144 characters in body
|
| Dec 10, 2019 at 8:40 | comment | added | Denis Sheremet |
Please note that in C way you should call free afterwards manually to avoid memory leakage
|
|
| Dec 10, 2019 at 8:37 | history | answered | bolov | CC BY-SA 4.0 |