SDDSlib
Loading...
Searching...
No Matches
compress.c File Reference

Provides a string manipulation function. More...

#include "mdb.h"
#include <ctype.h>

Go to the source code of this file.

Functions

char * compressString (char *s, char *t)
 Eliminates repeated occurrences of characters in string t from string s.
 

Detailed Description

Provides a string manipulation function.

This file contains functions to create, manage, and manipulate buffers that store lines of text strings. Buffers can be dynamically created, added to, cleared, and printed to files.

License
This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.
Author
C. Saunders, R. Soliday

Definition in file compress.c.

Function Documentation

◆ compressString()

char * compressString ( char * s,
char * t )

Eliminates repeated occurrences of characters in string t from string s.

This function removes consecutive duplicate characters in string s that are present in string t.

Parameters
sPointer to the string to be compressed. The string is modified in place.
tPointer to the string containing characters to remove from s.
Returns
Pointer to the compressed string s.

Definition at line 32 of file compress.c.

32 {
33 register char *ptr, *ptr0, *tptr;
34
35 ptr = ptr0 = s;
36 while (*ptr0) {
37 tptr = t;
38 while (*tptr) {
39 if (*tptr != *ptr0) {
40 tptr++;
41 continue;
42 }
43 while (*++ptr0 == *tptr)
44 ;
45 tptr++;
46 ptr0--;
47 }
48 *ptr++ = *ptr0++;
49 }
50 *ptr = 0;
51 return (s);
52}