SDDSlib
Loading...
Searching...
No Matches
SDDS
mdblib
insert.c
Go to the documentation of this file.
1
/**
2
* @file insert.c
3
* @brief Provides string manipulation function.
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 Inserts a substring into a target string.
21
*
22
* This function inserts the string `t` into the string `s` at the beginning.
23
* It is assumed that `s` has sufficient space to accommodate the additional characters.
24
*
25
* @param s Pointer to the destination string where `t` will be inserted.
26
* @param t Pointer to the source string to be inserted into `s`.
27
* @return Pointer to the modified string `s`.
28
*/
29
char
*
insert
(s, t)
char
*s;
/* pointer to character in string to insert at */
30
char
*t;
31
{
32
register
long
i, n;
33
34
n = strlen(t);
35
if
(n == 0)
36
return
(s);
37
38
for
(i = strlen(s); i >= 0; i--) {
39
s[i + n] = s[i];
40
}
41
42
for
(i = 0; i < n; i++)
43
s[i] = t[i];
44
45
return
(s);
46
}
insert
char * insert(char *s, char *t)
Inserts a substring into a target string.
Definition
insert.c:29
Generated by
1.12.0