C Language Development Kit/Snippets/String/TrimLeft

From OptiWiki

Jump to: navigation, search
Description Removes the specific leading characters from a string.
Syntax
char *TrimLeft( char *pszSource, char removeChar );
Arguments
char *pszSource
The source input string where the leading characters need be be remove from.
char removeChar
The specific key that is used to remove from the source input string.
Returns A pointer to the changed source input string.
Remarks The source input string is changed by this function.
Example
#include "lib.h"
#include <stdio.h>
#include "input.h"     //Holds the input functions
#include "strfunc.h"   //Holds the string manipulation functions
 
void main( void )
{
    static char dummy[ 21 ];
 
    for(;;)
    {
        strcpy( dummy, "      123456      ");
        printf("\forg:|%s|,", dummy );
        printf("new:|%s|\n", TrimLeft( dummy, ' ' ));
 
        printf("\npress a key");
        WaitForKey();
    }
}


Views
Personal tools