Guest_imported
New member
- Jan 1, 1970
- 0
I am using Borland Compiler 5.5.1. Does anyone have an idea on how to write a routine that will allow me to 'left trim' a string. Please correct the following program.
#include <string.h>
#include "EditUtil.h"
// Routine: leftTrim ()
// Programmer:
// Purpose: This routine trims in place from a c-string, leading tabs and spaces.
// Parameters: pString - type char * : The string to be left trimmed in place.
// Returns: Nothing
void leftTrim (char * pString )
{
int length = strlen ( pString ) ;
if ( length == 0 ) return ;
// char ch ;
int i, j, k;
bool found;
// Starting at the beginning of the string, move towards the end until you find a non space and non tab
// character
found = false;
for ( i = 0 ; i < length ; i ++ )
{
// ch = pString [ i ];
// if ( ch ! = TAB && ch ! = SPACE )
{
j = i;
found = true;
break;
}
} //
//
if ( found == true ) {
for ( k = 0 ; k < length - j ; k + 1 );
}
pString [ k ] = pString [ j + k ];
{
pString [ k ] = NULL_TERMINATOR;
}
pString [ 0 ] = NULL_TERMINATOR;
{
}
}
#include <string.h>
#include "EditUtil.h"
// Routine: leftTrim ()
// Programmer:
// Purpose: This routine trims in place from a c-string, leading tabs and spaces.
// Parameters: pString - type char * : The string to be left trimmed in place.
// Returns: Nothing
void leftTrim (char * pString )
{
int length = strlen ( pString ) ;
if ( length == 0 ) return ;
// char ch ;
int i, j, k;
bool found;
// Starting at the beginning of the string, move towards the end until you find a non space and non tab
// character
found = false;
for ( i = 0 ; i < length ; i ++ )
{
// ch = pString [ i ];
// if ( ch ! = TAB && ch ! = SPACE )
{
j = i;
found = true;
break;
}
} //
//
if ( found == true ) {
for ( k = 0 ; k < length - j ; k + 1 );
}
pString [ k ] = pString [ j + k ];
{
pString [ k ] = NULL_TERMINATOR;
}
pString [ 0 ] = NULL_TERMINATOR;
{
}
}