Export (0) Print
Expand All
Expand Minimize

_strtoi64, _wcstoi64

Convert a string to an __int64 value.

__int64 _strtoi64(
   const char *nptr,
   char **endptr,
   int base 
);
__int64 _wcstoi64(
   const wchar_t *nptr,
   wchar_t **endptr,
   int base 
);

Parameters

nptr
Null-terminated string to convert.
endptr
Pointer to character that stops scan.
base
Number base to use.

Return Value

_strtoi64 returns the value represented in the string nptr, except when the representation would cause an overflow, in which case it returns I64_MAX or I64_MIN. The function will return 0 if no conversion can be performed. _wcstoi64 returns values analogously to strtoi64.

I64_MAX and I64_MIN are defined in Limits.h.

See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, return codes.

Remarks

The _strtoi64 function converts nptr to a __int64. Both functions stop reading the string nptr at the first character they cannot recognize as part of a number. This may be the terminating null character, or it may be the first numeric character greater than or equal to base. _wcstoi64 is a wide-character version of _strtoi64; its nptr argument is a wide-character string. Otherwise these functions behave identically.

Generic-Text Routine Mappings

TCHAR.H routine _UNICODE & _MBCS not defined _MBCS defined _UNICODE defined
_tcstoi64 _strtoi64 _strtoi64 _wcstoi64

The current locale's LC_NUMERIC category setting determines recognition of the radix character in nptr; for more information, see setlocale. If endptr is not NULL, a pointer to the character that stopped the scan is stored at the location pointed to by endptr. If no conversion can be performed (no valid digits were found or an invalid base was specified), the value of nptr is stored at the location pointed to by endptr.

_strtoi64 expects nptr to point to a string of the following form:

[whitespace] [{+ | }] [0 [{ x | X }]] [digits]

A whitespace may consist of space and tab characters, which are ignored; digits are one or more decimal digits. The first character that does not fit this form stops the scan. If base is between 2 and 36, then it is used as the base of the number. If base is 0, the initial characters of the string pointed to by nptr are used to determine the base. If the first character is 0 and the second character is not 'x' or 'X', the string is interpreted as an octal integer; otherwise, it is interpreted as a decimal number. If the first character is '0' and the second character is 'x' or 'X', the string is interpreted as a hexadecimal integer. If the first character is '1' through '9', the string is interpreted as a decimal integer. The letters 'a' through 'z' (or 'A' through 'Z') are assigned the values 10 through 35; only letters whose assigned values are less than base are permitted.

Requirements

Routine Required header Compatibility
_strtoi64 <stdlib.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP
_wcstoi64 <stdlib.h> or <wchar.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.

See Also

Data Conversion Routines | Locale Routines | strtod Functions Overview | strtod | strtoul | atof | localeconv | setlocale | Run-Time Routines and .NET Framework Equivalents

Show:
© 2014 Microsoft