C Standard Libraries C++

wcstod()

Declaration

double wcstod(const wchar_t* kwpString, wchar_t** wppEndPtr);

Description

This function converts the numeric wide-characters of "kwpString" into a double value that is returned by the function. 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"3.14159XoaX.net";
    wchar_t* wpEndPtr;

    // Convert the digits and set the end pointer
    double dConversion = wcstod(waString, &wpEndPtr);
    wprintf(L"Convert the string \"%ws\" up to \"%ws\"\n",
        waString, wpEndPtr);
    wprintf(L"The result is %f\n", dConversion);

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

Output

wcstod() Output
 

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