SDDSlib
Loading...
Searching...
No Matches
delete_chars.c
Go to the documentation of this file.
1/**
2 * @file delete_chars.c
3 * @brief Implementation of string manipulation routine.
4 *
5 * @copyright
6 * - (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
7 * - (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
8 *
9 * @license
10 * This file is distributed under the terms of the Software License Agreement
11 * found in the file LICENSE included with this distribution.
12 *
13 * @author M. Borland, C. Saunders, R. Soliday
14 */
15
16#include "mdb.h"
17#include <ctype.h>
18
19/**
20 * @brief Removes all occurrences of characters found in string `t` from string `s`.
21 *
22 * This function iterates through each character in `s` and removes it if it appears in `t`.
23 *
24 * @param s The input string from which characters will be removed. It is modified in place.
25 * @param t The string containing characters to be removed from `s`.
26 * @return A pointer to the modified string `s`.
27 */
28char *delete_chars(char *s, char *t) {
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 * delete_chars(char *s, char *t)
Removes all occurrences of characters found in string t from string s.
char * strcpy_ss(char *dest, const char *src)
Safely copies a string, handling memory overlap.
Definition str_copy.c:34