+ 12
Concatenate wchar_t* in C++
Hi everybody, I want to concatenate two wchar_t* but error. Help me, please. #include <iostream> using namespace std; int main() { wchar_t* name1 = L"Sơn"; wchar_t* name2 = L"Văn"; wchar_t* name3; // I want to concatenate two name1 and name2!!! wcscat_s(name1, 4, name2); wprintf_s(L"%ls\n", name1); system("pause"); return 0; }
6 ответов
+ 9
Thank all my friend.
I have solved the problem.
+ 7
My problems are to use wchar_t* and unicode.
+ 6
#include <iostream>
#include <fcntl.h>
#include <io.h>
using namespace std;
int main()
{
//Changes console to UTF-16
_setmode(fileno(stdout), _O_U16TEXT);
wcout << L"\xfeff"; //Byte-order Mark
wchar_t name1[10] = L"Sơn";
wchar_t name2[] = L"Văn";
wchar_t* name3;
// I want to concatenate two name1 and name2!!!
wcsncat(name1, name2, 4);
wcout << name1 << endl;
return 0;
}