home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_300
/
352_01
/
strppsld.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1991-04-29
|
679b
|
23 lines
// STRPPSLD.CPP
// contains String::slide.
// routine to 'slide' portion of a string from right to left.
// input string: abcdefghi0
// positions: 0123456789 n =9 letters in string.
// cut ( 2, 5 ): abghi0 position 6 moved right to position 3
// new length n=5.
#include <stdlib.h>
#include <string.h>
#include "dblib.h"
void String::slide ( int start, int stop )
{
char *ss = s;
int sn = n;
if ( ss == NULL || sn ==0 ) return;
memmove ( ss+start, ss+ stop+1, sn-stop ); // also moves terminal /0
if ( 0 >= (n = sn - stop + start -1) )
destruct();
}
//------------------ end STRPPSLD.CPP --------------------