mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:47:34 +00:00
LibC: Implement stpcpy
For better code clarity, also reformatted how strcpy increments pointers.
This commit is contained in:
parent
8a43f5a64a
commit
75307803a2
2 changed files with 15 additions and 2 deletions
|
@ -187,11 +187,23 @@ void* memmem(void const* haystack, size_t haystack_length, void const* needle, s
|
|||
char* strcpy(char* dest, char const* src)
|
||||
{
|
||||
char* original_dest = dest;
|
||||
while ((*dest++ = *src++) != '\0')
|
||||
;
|
||||
while ((*dest = *src) != '\0') {
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
return original_dest;
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/stpcpy.html
|
||||
char* stpcpy(char* dest, char const* src)
|
||||
{
|
||||
while ((*dest = *src) != '\0') {
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncpy.html
|
||||
char* strncpy(char* dest, char const* src, size_t n)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue