#include <stdio.h>
#include <ctype.h>

void trim (char *s)
{
    int i;

    while (isspace (*s)) s++;   // skip left side white spaces
    for (i = strlen (s) - 1; (isspace (s[i])); i--) ;   // skip right side white spaces
    s[i + 1] = '\0';
    printf ("%s\n", s);
}

int main(void) {
    char str[] = "Hello World     ";
    printf("%s!!\n", str);
    trim(str);
    printf("%s!!\n", str);
}