I don't know what i did wrong, the program returns some weird and incomplete string : I was tring to to write a function that deletes whitespaces from a string but the output is not reasonable at all. I need help fam!

        char * deleteSpace(char *String, int n) {
    int i;
    char *withoutSpaces;
    withoutSpaces = calloc(n, sizeof (char));
    for (i = 0; i < n - 1; i++) {
        if (String[i] == ' ')
            withoutSpaces[i] = String[++i];
        else
            withoutSpaces[i] = String[i];
    }
    return withoutSpaces;
}