String Concatenation in C with Pointers
<p>So this is the standard string concatenation code in C:</p>

<pre><code>char *stringcat(char *dest, const char *src){
    char *save=dest;
    while(*save !='\0'){
        save++;
    }
    while(*src!='\0'){
        *save=*src;
        save++;
        src++;
    }
    *save='\0';
    return dest;
}
</code></pre>

<p>My question is why when we replace the first while loop with the following:</p>

<pre><code>while(*save++){};
</code></pre>

<p>It does not work, but, when replaced with:</p>

<pre><code>while(*++save){};
</code></pre>

<p>It does work.  In the first two instances, save points to the null terminator at the end of dest at the end, which is then overwritten by the first character in src.  However, in the third instance, it seems like save will be pointing to the character <strong>after</strong> the null terminator, which is weird.  </p>