I'm working at a super-simple program that if we enters a name, and it prints the entered name. It's easy but the problem is I live in korea and it's the hangeul(korean alphabet) so it must support hangeul
I tried this code:
#include <iostream>
#include <string>
using namespace std;
int main () {
string name = "";
cout << "이름을 입력하세요: "; getline(cin, name);
cout << "당신의 이름은 " << name << "입니다.";
return 0;
}
If we make it to english it will be:
#include <iostream>
#include <string>
using namespace std;
int main () {
string name = "";
cout << "Enter your name: ";
getline(cin, name);
cout << "Your name is " << name << ".";
return 0;
}
Looks easy. but if we put the hangeul in that cin,
Print:
Enter your name: 이름
Your name is .
and it just end. Of course the answer I wanted is:
Print:
Enter your name: 이름
Your name is 이름.
I've tried everything like using wide-character, change system locale and other many thing. Here's the code I've tried:
#include <iostream>
#include <string>
using namespace std;
int main () {
setlocale(LC_ALL, "Korean");
string name = "";
cout << "이름을 입력하세요: ";
getline(cin, name);
cout << "당신의 이름은 " << name << "입니다.";
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main () {
wstring name = "";
cout << "이름을 입력하세요: ";
getline(wcin, name);
wcout << "당신의 이름은 " << name << "입니다.";
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main () {
wstring name = "";
cout << "이름을 입력하세요: ";
getline(wcin, name);
cout << "당신의 이름은 ";
wcout << name;
cout << "입니다.";
return 0;
}
If you can, please help me!