Closed alekmaul closed 4 days ago
Although this code is trivial it might help in the meantime:
char* str_dup(const char* s)
{
u8 len = strlen(s);
char* res = malloc(len + 1);
u8 i;
for (i = 0; i < len; i++)
res[i] = s[i];
res[len] = '\0';
return res;
}
Homework: Use memcpy
Yeah, I agree but my goal is to translate it in 65C816 assembly code ;)
it is too much complicated to add it. I will remove the declaration from the .h file and close the issue. sorry :(
From REHvolution2024: Can you tell my why strdup is not found, although it's in string.h: Reference to an unknown label "strdup". I just want a mutable string, that's all. (Sure I know how to write my own strdup, but if it's available I want to use this one.)