Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Destructivly strip a bounded substring out of a string
- * remove (), <>, [], {} etc and their contents
- *
- * Returns 1 (Success) or 0 (Fail)
- */
- int stripout(char *_caStBuff, char _leftboundary, char _rightboundary) {
- int iLoop,
- iStrLen,
- iLeft,
- iRight ;
- iLeft = (-1) ;
- iRight = (-1) ;
- iStrLen = strlen( _caStrBuff ) ;
- if ( iStrLen < 1 ) {
- // I can't help you
- return 0 ;
- }
- // find boundery indexs
- for (iLoop = 0; iLoop < iStrLen; ++iLoop) {
- if (_caStrBuff[iLoop] == _leftboundary) {
- iLeft = iLoop ;
- } else if (_caStrBuff[iLoop] == _rightboundary) {
- iRight = iLoop ;
- } else {
- }
- } // find indexs
- if ((iLeft > 0) && (iRight > iLeft) ) {
- strcpy( &_caStrBuff[ iLeft-1 ], &_caStrBuff[ iRight+1 ] ) ;
- return 1 ;
- } else if ( (iLeft == 0) && (iRight > iLeft) ) {
- strcpy( _caStrBuff, &_caStrBuff[ iRight+1 ] ) ;
- return 1 ;
- } else {
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement