C Standard Libraries C++

mbsinit()

Declaration

int mbsinit(const mbstate_t* kqpMBState);

Description

This function checks whether the multibyte shift state pointed to by "kqpMBState" is in the initial shift state. If so or if "kqpMBState" is NULL, the function returns a nonzero value. Otherwise, the function returns 0.

Example

#include <iostream>
#include <cwchar>

int main()
{
    using namespace std;
    const char* kcpName = "XoaX.txt";
    wchar_t waWideString[10];

    mbstate_t qState;
    // Convert the string kcpName
    size_t qReturn = mbsrtowcs(waWideString, &kcpName, 9, &qState);
    // Check whether the shift state is in the initial state
    if (0 == mbsinit(&qState)) {
        cout << "Not Initial Shift State" << endl;
    } else {
        cout << "Initial Shift State" << endl;
    }
    // Check whether the call was successful.
    if (qReturn < 0) {
        cout << "Error!" << endl;
    } else {
        cout << "Conversion length = " << qReturn << endl;
        wcout << "Converted wide string = " << waWideString << endl;
    }
    return 0;
}

Output

mbsinit() Output
 

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