Function comments (v1)
This commit is contained in:
@@ -6,6 +6,16 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/*
|
||||
* strcpy - copy a NULL-terminated string
|
||||
* @dest: destination buffer where the string is copied
|
||||
* @src: source string to copy from
|
||||
*
|
||||
* Copies the string pointed to by @src (including the terminating
|
||||
* NULL byte) into the buffer pointed to by @dest.
|
||||
*
|
||||
* Return: pointer to the destination string (@dest)
|
||||
*/
|
||||
char* strcpy(char *dest, const char *src)
|
||||
{
|
||||
char *temp = dest;
|
||||
@@ -13,7 +23,21 @@ char* strcpy(char *dest, const char *src)
|
||||
return temp;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/2488563/strcat-implementation
|
||||
/*
|
||||
* strcat - append a NUL-terminated string
|
||||
* @dest: destination buffer containing the initial string
|
||||
* @src: source string to append
|
||||
*
|
||||
* Appends the string pointed to by @src to the end of the string
|
||||
* pointed to by @dest. The terminating NUL byte in @dest is
|
||||
* overwritten and a new terminating NUL byte is added.
|
||||
*
|
||||
* The destination buffer must be large enough to hold the result.
|
||||
*
|
||||
* Taken from: https://stackoverflow.com/questions/2488563/strcat-implementation
|
||||
*
|
||||
* Return: pointer to the destination string (@dest)
|
||||
*/
|
||||
char *strcat(char *dest, const char *src)
|
||||
{
|
||||
size_t i,j;
|
||||
@@ -26,7 +50,21 @@ char *strcat(char *dest, const char *src)
|
||||
return dest;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/14159625/implementation-of-strncpy
|
||||
/*
|
||||
* strncpy - copy a string with length limit
|
||||
* @dst: destination buffer
|
||||
* @src: source string
|
||||
* @n: maximum number of bytes to copy
|
||||
*
|
||||
* Copies up to @n bytes from @src to @dst. Copying stops early if a
|
||||
* NULL byte is encountered in @src. If @src is shorter than @n, the
|
||||
* remaining bytes in @dst are left unchanged in this implementation.
|
||||
*
|
||||
* Note: This differs slightly from the standard strncpy behavior,
|
||||
* which pads the remaining bytes with NULL.
|
||||
*
|
||||
* Taken from: https://stackoverflow.com/questions/14159625/implementation-of-strncpy
|
||||
*/
|
||||
void strncpy(char* dst, const char* src, size_t n)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
Reference in New Issue
Block a user