简体   繁体   中英

C++ gives an error

Hello I have an error at this program that is wcout is not a member of `std'. Also I used iostream as you see but didnt work.I have Dev-C++ 4.9.9.2 and my operating system is XP SP3 I need your help. Thanks for free time.

#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;
}

If you're compiling with MinGW, wide characters are not yet supported . If you really need it, an alternative is to use the STLPort library as an alternative to libstdc++.

Dev-C++ 4.9.9.2 that you're using comes with MinGW-gcc 3.4.2 which is 7+ years old , likely doesn't have wide-chars properly supported as suggested by sftrabbit.

If you look at the top of the original Dev-C++ at sourceforge you'll see that its been superseded by Orwell Dev-C++ . I would suggest using that if you need wide-char support since it packages a much more recent version of MinGW-gcc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM