4 ms·
It's a good solution for strncat for sure! I'd guess that the majority of strncpy calls look something like: char *x = calloc(n, 1); strncpy(x, y, n -
by haldean 8y ago
It's a good solution for strncat for sure! I'd guess that the majority of strncpy calls look something like:
char *x = calloc(n, 1);
strncpy(x, y, n - 1);
Which can be replaced with:
char *x = strdup(y);
Which is both one line shorter and 100% less error prone!