0
0
GGGiovanny Gongora
Whitespace is defined by isspace(). Returns s, modified to be terminated at the start of its trailing whitespace.
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
char *
rtrim(char *s) {
char *p = s + strlen(s) - 1;
while (p >= s && isspace((unsigned char) *p)) {
*p = '\0';
p--;
}
return s;
}