Why is this string not properly terminated with a null character?
char *copy(char *dest, const char *src, int capacity) {
    for (int i = 0; i < capacity - 1; i++){
            dest[i] = src[i];
    }
    dest[capacity] = '\0';
    return dest;
}