Designing a better strcpy
&gt; In the case where src fits in dst, it will return a pointer past the NUL byte it placed; otherwise it returns NULL to indicate a truncation.<p>It is amazing to me how personal these preferences are ;P... like, I&#x27;d be much happier with an API that always returns the location of the NUL byte on success; and, if the string gets truncated, then it instead returns dst+len (the address of the byte past the end of the buffer). This allows for chained constructions that provide efficient strcat-style semantics with easy error propagation, such as this example which concatenates three strings (which I honestly hope I got right... I&#x27;m giving reasonable odds to Saagar telling me I&#x27;ve coded a buffer overflow by accident somewhere ;P):<p><pre><code>    char buf[X]; &#x2F;&#x2F; for any X, even 0!
    char *cur = buf;
    char *end = buf + sizeof(buf);
    cur = strjcpy(cur, str1, end - cur);
    cur = strjcpy(cur, str2, end - cur);
    cur = strjcpy(cur, str3, end - cur);
    if (cur == end) goto fail;</code></pre>