SDDS ToolKit Programs and Libraries for C and Python
All Classes Files Functions Variables Macros Pages
delete_chars.c File Reference

Detailed Description

Implementation of string manipulation routine.

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

Definition in file delete_chars.c.

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

Go to the source code of this file.

Functions

char * delete_chars (char *s, char *t)
 Removes all occurrences of characters found in string t from string s.
 

Function Documentation

◆ delete_chars()

char * delete_chars ( char * s,
char * t )

Removes all occurrences of characters found in string t from string s.

This function iterates through each character in s and removes it if it appears in t.

Parameters
sThe input string from which characters will be removed. It is modified in place.
tThe string containing characters to be removed from s.
Returns
A pointer to the modified string s.

Definition at line 28 of file delete_chars.c.

28 {
29 char *ps, *pt;
30
31 ps = s;
32 while (*ps) {
33 pt = t;
34 while (*pt) {
35 if (*pt == *ps) {
36 strcpy_ss(ps, ps + 1);
37 ps--;
38 break;
39 }
40 pt++;
41 }
42 ps++;
43 }
44 return (s);
45}
char * strcpy_ss(char *dest, const char *src)
Safely copies a string, handling memory overlap.
Definition str_copy.c:34