天天看點

c++用wcout輸出寬字元

偶然想起如何用c++直接輸出寬字元,是以還是記下來吧

# include<iostream>
using namespace std;

int main()
{
    //要想輸出寬字元,加上這句就可以了
    wcout.imbue(locale("", LC_CTYPE));

    wchar_t str[] = L"寬字元";
    char s[] = "字元";
    cout << sizeof(str) << endl;
    wcout << str << endl;
    cout << s << endl;
    cout << sizeof(s) << endl;
    wchar_t ch = L'7';
    wcout << ch << endl;
    system("pause");
    return ;
}
           
c++用wcout輸出寬字元