wide characters

#include "stdafx.h"
#include <iostream>
#include <string>

int main()
{
std::cout << "Please enter your first name: ";

std::string name;
std::cin >> name;

std::cout << "Hello, " << name << "!" << std::endl;
return 0;
}

wchar_t

where do i put this in for wide characters like japanese?

thanx

[468 byte] By [Akid] at [2007-12-24]
# 1
String class defined using template class basic_string with type char
Sarath. at 2007-8-31 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 2
i'm sorry i'm 14. don't knw wht that site was saying. be nice if u taught me how the program would be with it. thanx
Akid at 2007-8-31 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 3

You need to replace cout, cin and string with wcout, wcin and wstring. You will also need to add the L prefix to string constants to make them wide strings:

#include "stdafx.h"
#include <iostream>
#include <string>

int main()
{
std::wcout << L"Please enter your first name: ";

std::wstring name;
std::wcin >> name;

std::wcout << L"Hello, " << name << L"!" << std::endl;
return 0;
}

MikeDanes at 2007-8-31 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 4

o i get it

thanx u've helped me a lot

Akid at 2007-8-31 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 5

From yesterday onwards I'm trying to post my reply. the reply automcatically posted to the forum while I was typing. after that I could not edit it. always showing error.Even I could not delete my answer :( please see my complete reply.

String class defined using template class basic_string

with type char

You can use wstring instead of string class. wstring also defined in std.

See MSDN for

more details.

Sarath. at 2007-8-31 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 6

If you need your program to compile both for ANSI and UNICODE, you can utilize TCHAR and define a string of your own:

typedef std::basic_string<TCHAR> tstring;

MariusBancila at 2007-8-31 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 7
so where am i supposed to put that in?
Akid at 2007-8-31 > top of Msdn Tech,Visual C++,Visual C++ Language...