News for hackers. Stuff that matters.
Re:Why Does Software Rot? by kazinator on Saturday June 25, 2016 @01:32PM (#11977130)
strncpy is strcpy's daft cousin that wastefully writes extra null characters---except when there is no room; then it neglects to null-terminate at all.

strncpy was not needed even in C90, because of sprintf, which is less clumsy to use, doing everything in one step:

  char array[64];
  sprintf(array, "%.63s", some_string);
If we replace the 63 with * , we can pass a dynamic size:

  sprintf(array, "%.*s", (int) sizeof array - 1, some_string);

There are no comments on this comment yet.