3 ms·
Strncpy gives back the length copied which you can use to append more text: char buf[1024]; size_t pos = 0; int ret = snprintf(buf, sizeof(buf), src
by legulere 8y ago
Strncpy gives back the length copied which you can use to append more text:
char buf[1024];
size_t pos = 0;
int ret = snprintf(buf, sizeof(buf), src1);
if(ret >= 0) { pos += ret } else { error() }
ret = snprintf(buf + pos, sizeof(buf) - pos, src2);
...