2013-03-22 99 views
2

你好我在这个程序,它是wcout不是`STD”的成员的错误。我也使用iostream,因为你看到,但没有工作。我有Dev-C++ 4.9.9.2和我的操作系统是XP SP3 我需要你的帮助。 感谢您的空闲时间。C++提供了一个错误

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

您是否尝试过[DEV-C++使用MinGW]的最新版本(http://sourceforge.net/projects/orwelldevcpp/files/Portable%20Releases/)? ? – greatwolf 2013-03-23 00:07:13

+0

我现在同样的问题,试图:( – thomas123 2013-03-23 00:20:02

+0

你尝试新的人之前先卸载旧版本我只是测试它,它为我编译罚款[输出C++打错一个字母(HTTP的 – greatwolf 2013-03-23 00:39:31

回答

1

您正在使用的Dev-C++ 4.9.9.2附带MinGW-gcc 3.4.2,它是7+ years old,可能没有像sftrabbit建议的那样正确支持宽字符。

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

4

如果您使用MinGW,wide characters are not yet supported进行编译。如果您真的需要它,另一种方法是使用STLPort库作为libstdC++的替代品。

+2

搞怪,无论'wcout'和'wstring'已经工作了,只要我可以用我的MinGW记得。 – chris 2013-03-23 00:03:43

+0

@克里斯也许最近已经并且提问者正在使用旧版本?该页面尚未更新。 – 2013-03-23 00:05:29

+0

可能。我注意到MinGW站点的某些部分在过去未被维护。 – chris 2013-03-23 00:33:07