Logo Search packages:      
Sourcecode: bglibs version File versions

long str_subst ( str s,
char  from,
char  to 
)

Substitute one character for another throughout the string.

Returns:
the number of substitutions made.

Definition at line 24 of file subst.c.

References len, and s.

{
  char* ptr;
  unsigned i;
  long count;
  for (count = 0, i = 0, ptr = s->s; i < s->len; ++i, ++ptr)
    if (*ptr == from) {
      *ptr = to;
      ++count;
    }
  return count;
}


Generated by  Doxygen 1.6.0   Back to index