16 lines
611 B
C
16 lines
611 B
C
/* This header file defines a strzcpy function, for general string copying (that is safer). */
|
|
#ifndef STRZCPY_H
|
|
#define STRZCPY_H
|
|
/* Include string.h */
|
|
#include <string.h>
|
|
|
|
|
|
/**
|
|
* This function takes a destination buffer, a source buffer and a length.
|
|
* Copies the source into the destination, stopping when length is reached or end of destination (whichever is shorter).
|
|
* The copied string is always null-terminated when possible (might cause truncation).
|
|
* Will return the length copied (and if it overflowed).
|
|
*/
|
|
char *strzcpy(char *restrict dst, const char *restrict src, size_t len);
|
|
#endif //STRZCPY_H
|