summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/rmallws.c
blob: 84ca8a0e665cd71a9d4a0b2678919a0a440e90d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
**  Originally published as part of the MicroFirm Function Library
**
**  Copyright 1986, S.E. Margison
**  Copyright 1989, Robert B.Stout
**
**  Subset version released to the public domain, 1991
**
**  remove all whitespace from a string
*/

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

#define NUL '\0'

char *rmallws(char *str)
{
      char *obuf, *nbuf;

      for (obuf = str, nbuf = str; *obuf && obuf; ++obuf)
      {
            if (!isspace(*obuf))
                  *nbuf++ = *obuf;
      }
      *nbuf = NUL;
      return str;
}