When moving strings between buffers, I frequently treat char*
as data buffers, and use none of the string buffer (strncpy
, strncat
, etc).
Example:
memcpy(target, src, strlen(src) + 1) // after buffer size checks
//vs
strncpy(target, src, target_size - 1);
target[target_size - 1] = 0;
Is this a bad practice?
EDIT: I know the difference, this is not a duplicate, but rather a question of standard practice.