fork download
  1. #include <iostream>
  2. #include <map>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. wchar_t str[] = L"おえいうあ";
  8. map<wchar_t, int> charactor_to_handle = {
  9. { L'あ', 0 },
  10. { L'い', 1 },
  11. { L'う', 2 },
  12. { L'え', 3 },
  13. { L'お', 4 },
  14. };
  15. int n[256] = { 100, 200, 300, 400, 500 };
  16.  
  17. for(int i = 0; i < wcslen(str); ++i) {
  18. wcout << n[charactor_to_handle[str[i]]] << endl;
  19. }
  20.  
  21. cin.get();
  22. return 0;
  23. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:14:5: error: in C++98 ‘charactor_to_handle’ must be initialized by constructor, not by ‘{...}’
     };
     ^
prog.cpp:14:5: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
prog.cpp:14:5: error: could not convert ‘{{12354, 0}, {12356, 1}, {12358, 2}, {12360, 3}, {12362, 4}}’ from ‘<brace-enclosed initializer list>’ to ‘std::map<wchar_t, int>’
prog.cpp:17:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < wcslen(str); ++i) {
                                  ^
stdout
Standard output is empty