C Standard Libraries C++



int swscanf(const wchar_t* kwpBuffer,
            const wchar_t* kwpFormatString, ...);


This function reads data from the wide character string "kwpBuffer" and put them into the arguments passed in after the formatted string. The string "kwpFormatString" specifies how data is read into the arguments. The function returns an integer to indicate how many arguments were successfully read. Otherwise, the function returns WEOF to indicate an error or that the end of the string was reached before an argument was read.


#include <cwchar>

int main()
    const wchar_t kwaBuffer[] = L"XoaX.net 87";
    wchar_t waString[11];
    int iInteger = 0;

    // Read a string of max size 10 and then an integer
    int iSize = swscanf(kwaBuffer, L"%10ws %d", waString, &iInteger);
    wprintf(L"String = %ws\n", waString);
    wprintf(L"int = %d\n", iInteger);
    wprintf(L"%d arguments read.\n", iSize);

    // Keep the window open until "Enter" is pressed
    return 0;


swscanf() Output

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