DEV Community

Discussion on: Daily Challenge #1 - String Peeler

Collapse
 
overlordex3 profile image
Exequiel Beker

I tried to not use any str function.

char* trimFirstAndLastLetters(char* str)
{
    int index = 1;

    if(str[0] == '\0' || str[1] == '\0') {
        return NULL;
    }

    while(*(str + index) != '\0') {
        *(str + (index - 1)) = *(str + index);
        index++;
    }

    /* Remove last one */
    *(str + (index - 2)) = '\0';
    return str;
}