Consider:
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
wstring str = L"こんにちは";
wcout << str << endl;
system("pause");
}
I am trying to print Japanese (hello ) from a C++ program, but I am getting an error. I have saved this program in Notepad using Unicode encoding and then compiled it using MinGW 4.7.2, but I get the following error:
cd "E:\GCC test"
g++ -c unicode.cpp
Output:
unicode.cpp:1:1: error: stray '\377' in program
unicode.cpp:1:1: error: stray '\376' in program
unicode.cpp:1:1: error: stray '#' in program
unicode.cpp:3:4: error: invalid preprocessing directive #i
unicode.cpp:5:4: error: invalid preprocessing directive #i
unicode.cpp:1:5: error: 'i' does not name a type
unicode.cpp:11:2: error: 'i' does not name a type