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]
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;
}
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.
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;