StrToIntA function (shlwapi.h)

Converts a string that represents a decimal value to an integer. The StrToLong macro is identical to this function.


int StrToIntA(
  [in] PCSTR pszSrc


[in] pszSrc


A pointer to the null-terminated string to be converted. A valid string representing a decimal value contains only the characters 0-9 and must have the following form to be parsed successfully.

(optional white space)(optional sign)(one or more decimal digits)

The optional sign can be the character '-' or '+'; if omitted, the sign is assumed to be positive.

Return value

Type: int

Returns the int value represented by pszSrc. For instance, the string "123" returns the integer value 123.


If the string pointed to by pszSrc contains an invalid character, that character is considered the end of the string to be converted and the remainder is ignored. For instance, given the invalid decimal string "12b34", StrToInt only recognizes "12" and returns that integer value.


The shlwapi.h header defines StrToInt as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


Requirement Value
Minimum supported client Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header shlwapi.h
Library Shlwapi.lib
DLL Shlwapi.dll (version 4.71 or later)

See also