I need to remove the first 3 characters from an array without any libraries. How would I go about doing this? I know that I can use memmove
but I'm working on a system without the standard library, also memmove
is for pointers. With memmove
I can do this:
void chopN(char *str, size_t n)
{
assert(n != 0 && str != 0);
size_t len = strlen(str);
if (n > len)
return; // Or: n = len;
memmove(str, str+n, len - n + 1);
}
But could I remove characters from an array without memmove
or any other standard library functions?
As long as you know the string is at least 3 characters long, you can simply use str + 3
.