c++给出了一个错误

C++ gives an error

本文关键字:一个 错误 c++      更新时间:2023-10-16

你好,我在这个程序中有一个错误,那就是wcout不是' std'的成员。此外,我使用iostream,如你所见,但没有工作。我有dev - c++ 4.9.9.2和我的操作系统是XP SP3我需要你的帮助。谢谢你的宝贵时间。

#include <iostream>
#include <cstring>
#include <cwchar>
using namespace std;
const wchar_t alphabet[] ={'A', 'B', 'C', 'Ç', 'D', 'E', 'F', 'G', 'Ğ', 'H', 'I',
                        'İ', 'J', 'K', 'L', 'M', 'N', 'O', 'Ö', 'P', 'R', 'S',
                        'Ş', 'T', 'U', 'Ü', 'V', 'Y', 'Z', '0', '1', '2', '3',
                        '4', '5', '6', '7', '8', '9', '.', ',', ':', ';', ' '};
const int char_num =44;
void cipher(wchar_t word[], int count, int key)
{
    int i = 0;
    while(i < count) {
        int ind = -1;
        while(alphabet[++ind] != word[i]) ;
        ind += key;
        if(ind >= char_num)
            ind -= char_num;
        word[i] = alphabet[ind];
        ++i;
    }
}
void decipher(wchar_t word[], int count, int key)
{
    int i = 0;
        while(i < count) {
        int ind = -1;
        while(alphabet[++ind] != word[i]) ;
        ind -= key;
        if(ind < 0)
            ind += char_num;
        word[i] = alphabet[ind];
        ++i;
    }
}
int main()
{
    wchar_t text[] = L"ABJT;";
    int len = wcslen(text);
    std::wcout << text << std::endl;
    cipher(text, len, 2);
    std::wcout << text << std::endl;
    decipher(text, len, 2);
    std::wcout << text << std::endl;
    return 0;
}

如果使用MinGW编译,则还不支持宽字符。如果您确实需要它,另一种选择是使用STLPort库作为libstdc++的替代品。

您正在使用的dev - c++ 4.9.9.2附带了MinGW-gcc 3.4.2,它已经7年多了,可能没有像sftrabbit建议的那样正确支持宽字符。

如果你在sourceforge上查看原始dev - c++的顶部,你会发现它已经被Orwell dev - c++取代了。如果您需要宽字符支持,我建议使用它,因为它包含了最新版本的MinGW-gcc。

相关文章: