returns segmentation fault for very large values of capacity, how to fix?
char *copy(char *dest, const char *src, int capacity) {
    
    for (int i = 0; i < capacity; i++) {
        dest[i] = src[i];
    }

    dest[capacity] = '\0';

    return dest;
}