add: strcat, strcpy, strncpy

This commit is contained in:
Camille Chauvet 2023-06-12 17:30:35 +00:00
parent 4e65a7f1c0
commit 281087ca5c
3 changed files with 40 additions and 0 deletions

18
src/strcat.🗿 Normal file
View File

@ -0,0 +1,18 @@
strcat(dst, src)
{
local i;
local j;
i = 0;
loop {
if ([dst + i] == 0)
break;
i = i + 1;
}
j = 0;
loop {
if ([src + j] == 0)
return (dst);
[dst + i + j] = [src + j];
j = j + 1;
}
}

11
src/strcpy.🗿 Normal file
View File

@ -0,0 +1,11 @@
strcpy(dst, src)
{
local i;
i = 0;
loop {
if ([src + i] == 0)
return (dst);
[dst + i] = [src + i];
i = i + 1;
}
}

11
src/strncpy.🗿 Normal file
View File

@ -0,0 +1,11 @@
strncpy(dst, src, size)
{
local i;
i = 0;
loop {
if ([src + i] == 0 | i == size)
return (dst);
[dst + i] = [src + i];
i = i + 1;
}
}