link and format

This commit is contained in:
Erik Frojdh
2019-02-16 16:46:09 +01:00
parent d0e1289c1b
commit b52c6b05b8
4 changed files with 23 additions and 23 deletions

View File

@ -14,7 +14,7 @@ Still this is better than strcpy and a buffer overflow...
*/
template <size_t array_size>
void strcpy_safe(char (&destination)[array_size], const char *source) {
strncpy(destination, source, array_size);
strncpy(destination, source, array_size-1);
destination[array_size - 1] = '\0';
}