Copy a string: Difference between revisions
→[[C]]: organized a bit more
(→[[Python]]: --- comment on object "interning") |
(→[[C]]: organized a bit more) |
||
Line 33:
dst$ = src$
==
▲ // Using strdup
const char* src = "Hello";
char* dst = strdup(src);
const char* src = "Hello";
int len = strlen(src);
Line 45 ⟶ 44:
strcpy(dst, src);
const char* src = "Hello";
int len = strlen(src);
Line 51 ⟶ 50:
strncpy(dst, src, len+1); dst[len] = 0;
const char* src= "Hello";
static char dst[80];
|