2.1.2.21 is_str_numeric_integer


Description

Check and convert a string to an integer

Syntax

BOOL is_str_numeric_integer( LPCSTR lpcszStr, int * lpnVal = NULL )

Parameters

lpcszStr
[input] string to check and convert
lpnVal
[output] optional pointer to hold resulting integer

Return

true if str can be converted to an integer ,otherwise false

Examples

EX1

void is_str_numeric_integer_ex1()
{
	int i = 0;
	string str = "-123";//change to "abc" or "123.456" to see different result;
	bool bRet = is_str_numeric_integer(str , &i);
	if(bRet)
		printf("\"%s\" is converted to %d \n" ,str ,i);
	else
		printf("\"%s\" can not be converted to an integer\n" ,str);
}

Remark

See Also

is_str_numeric_integer_with_args

Header to Include

origin.h

Reference