C Standard Libraries C++

wcstoul()

Declaration

unsigned long wcstoul(const wchar_t* kwpString,
                      wchar_t** wppEndPtr,
                      int iBase);

Description

This function converts the numeric wide-characters of "kwpString" into an unsigned long value using "iBase" as the number base and returns the value. The function stops the conversion and sets the "wppEndPtr" value at the first non-numeric character of "kwpString."

Example

#include <cwchar>

int main()
{
    wchar_t waString[] = L"101XoaX.net";
    wchar_t* wpEndPtr;

    // Convert the digits in decimal and set the end pointer
    unsigned long ulConversion = wcstoul(waString, &wpEndPtr, 10);
    wprintf(L"Convert the string \"%ws\" up to \"%ws\" in decimal\n",
        waString, wpEndPtr);
    wprintf(L"The result is %d\n", ulConversion);
    // Convert the digits in binary and set the end pointer
    ulConversion = wcstoul(waString, &wpEndPtr, 2);
    wprintf(L"Convert the string \"%ws\" up to \"%ws\" in binary\n",
        waString, wpEndPtr);
    wprintf(L"The result is %d\n", ulConversion);

    // Keep the window open until "Enter" is pressed
    getwchar();
    return 0;
}

Output

wcstoul() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.