strtol

 

Contents

Description

Converts a character string to a long int value.

Syntax

long strtol( const char * str, char ** endptr, int base )

Parameters

str
[input] Points to a character string to convert.
endptr
[output] if not NULL, returns a string beginning with the first character that strtol() does not attempt to convert.
base
[input] the base of the string, between 0 and 36.

Return

returns the converted integral number as a long int value, else zero value is returned.

Examples

EX1

void strtol_ex()
{
    long ret = strtol(" -0xa2", NULL, 16);    
    printf("%ld\n", ret);
}

Remark

See Also

ftoa

header to Included

origin.h

Reference