[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/string/wide/wcstol [Back]  [Original]

std::wcstol, std::wcstoll cppreference.com
cppreference.com

std::wcstol, std::wcstoll

cppreference.com
<tbody> </tbody>
long wcstol( const wchar_t* str, wchar_t** str_end, int base );
long long wcstoll( const wchar_t* str, wchar_t** str_end, int base );
( C++11)

, str.

( std::iswspace) , , -n ( n=base) . :

  • ()
  • () (0), (, 8 0)
  • () (0x 0X), (, 16 0)
  • .

{0,2,3,...,36}. 2 {0,1}, 3 {0,1,2}, . , 10, , Aa 11, Zz 36. .

C.

base 0, : 0, , 0x 0X, , .

, , , , .

, str_end, . str_end , .

str ,
str_end
base

, str . , LONG_MAX, LONG_MIN, LLONG_MAX LLONG_MIN. , 0.

#include <cwchar>
#include <errno.h>
#include <iostream>
#include <string>

int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");

    const wchar_t* p = L"10 200000000000000000000000000000 30 -40";
    wchar_t *end;
    std::wcout << L" L'" << p << "':\n";
    for (long i = std::wcstol(p, &end, 10); p != end; i = std::wcstol(p, &end, 10))
    {
        std::wcout << '\'' << std::wstring(p, end-p) << "' -> ";
        p = end;
        if (errno == ERANGE)
        {
            std::wcout << L" ,  ";
            errno = 0;
        }
        std::wcout << i << '\n';
    }
}

:

 L'10 200000000000000000000000000000 30 -40':
'10' -> 10
' 200000000000000000000000000000' ->  ,  9223372036854775807
' 30' -> 30
' -40' -> -40


() []

() []
C wcstol, wcstoll

Web Proxy Viewer  |  New URL  |  Original Page