diff options
Diffstat (limited to 'c/util.h')
-rw-r--r-- | c/util.h | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,6 +1,8 @@ #ifndef UTIL_H #define UTIL_H +#include <algorithm> +#include <cstring> #include <memory> /* Format static wide string. */ @@ -12,9 +14,11 @@ inline int Swprintf(wchar_t (&buf)[N], const wchar_t* const fmt, T... xs) /* Copy to static narrow string buffer. */ template <size_t N> -inline int Strcpy(char (&dst)[N], const char* const src) +inline char* Strcpy(char (&dst)[N], const char* const src) { - return strcpy_s(dst, N, src); + memcpy(dst, src, std::min(N, strlen(src))); + dst[N-1] = 0; + return dst; } inline int Cmp(const int a, const int b) |