Hello! It is confused me for a long time!
Long long ago , there is only ansi version that is atoi .
And now (it is also long long ago ) there is a wide char version .
But why the wide char version has a uderline('_') before wtoi?
Could any one tell me why? Thanks :)
For the most part, functions that begin with a leading underscore are implementation additions; they are not part of the C Standard Library. (There are exceptions, e.g. _Exit
is part of the C Standard Library, though it is not yet implemented in the Visual C++ implementation.) Identifiers that begin with a leading underscore are reserved in the global namespace, so they are used for nonstandard extensions to avoid conflict with user-defined names.
As for why there is no wtoi
in the C Standard Library: By the time wide character functions were added to the C Standard Library, it was understood that the atoi
interface is flawed because there is no way to detect whether the conversion succeeded or failed.
Do not use atoi
or _wtoi
. Instead, use the preferable strtol
and wcstol
functions, both of which are part of the C Standard Library. (There are other similarly-named conversion functions for other types, e.g. strtof
and wcstof
to convert to float
and strtoull
and wcstoull
to convert to unsigned long long
.)
Microsoft provides the functions _atoi_l, _wtoi, _wtoi_l
as vendor specific extensions. They are not standard C/C++ library functions. They have many such vendor specific functions that have names derived from standard C/C++ library functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With