is_str_numeric_integer_with_args

 

Description

Check and convert the substring before the separator token to an integer and return the remaining string

Syntax

LPSTR is_str_numeric_integer_with_args( LPSTR lpsz, int * lpnVal, char cSeparator = ':' )

Parameters

lpsz
[modify] string to check and convert, it will be modified by this function
lpnVal
[output] optional pointer to hold resulting integer
cSeparator
[input] separator, like ":"

Return

pointer to the buffer after the separator character with leading and trailing spaces removed, or NULL if leading part of string is not an integer

Examples

EX1

void is_str_numeric_integer_with_args_ex1()
{
        //convert the substring before the separator, return remain str    
        //change the  '/' to other separator to see differrent result
        int ii = 0;
        string  str = is_str_numeric_integer_with_args("123/ 456 ", &ii , '/'); 
        
        if( ("456" == str) && (123 == ii) )       
                printf("remain str is  \"%s\"  converted integer is %d\n", str , ii);
        else
                printf("convert failed\n");       
}

Remark

See Also

is_str_numeric_integer, is_str_numeric

header to Include

origin.h

Reference