generarxml/string.c
Chris Cromer 60f4d62594 readfile
2016-10-16 14:16:03 -03:00

28 lines
499 B
C

#include <string.h>
#include <ctype.h>
char *trim(char *str) {
char *end;
/* Trim leading space */
while (isspace((unsigned char) *str)) {
str++;
}
if(*str == 0) {
/* All spaces? */
return str;
}
/* Trim trailing space */
end = str + strlen(str) - 1;
while (end > str && (isspace((unsigned char) *end) || *end == '\r' || *end == '\n')) {
end--;
}
/* Write new null terminator */
*(end + 1) = 0;
return str;
}