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

Provides string manipulation function. More...

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

Go to the source code of this file.

Functions

char * insert (char *s, char *t)
 Inserts a substring into a target string.
 

Detailed Description

Provides string manipulation function.

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 insert.c.

Function Documentation

◆ insert()

char * insert ( char * s,
char * t )

Inserts a substring into a target string.

This function inserts the string t into the string s at the beginning. It is assumed that s has sufficient space to accommodate the additional characters.

Parameters
sPointer to the destination string where t will be inserted.
tPointer to the source string to be inserted into s.
Returns
Pointer to the modified string s.

Definition at line 29 of file insert.c.

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}