|
|
1.1 root 1: /*
2: * Remove trailing whitespace spaces from a line.
3: */
4: #include <ctype.h>
5: #include <stdio.h>
6: extern char *strchr();
7:
8: char *
9: trim(s)
10: char *s;
11: {
12: register char *p;
13:
14: if (NULL == (p = strchr(s, '\0')))
15: return (NULL);
16: for (--p; (p > s) && isascii(*p) && isspace(*p);)
17: *p-- = '\0';
18: return (s);
19: }
20: #ifdef TEST
21: main()
22: {
23: char buf[80];
24:
25: while (NULL != gets(buf))
26: printf("'%s'\n", trim(buf));
27: }
28: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.