K
Khanh01
Guest
Hello, I am having trouble with wchar_t,
This is the code I am having
TCHAR* promptPtrs1[] = {
const_cast<_TCHAR*>(L"\nSelect first group: "),
const_cast<_TCHAR*>(L"\nRemove first group: ")
};
TCHAR* promptPtrs2[] = {
const_cast<_TCHAR*>(L"\nSelect second group: "),
const_cast<_TCHAR*>(L"\nRemove second group: ")
};
I want to change the code to like this
const wchar_t str[10] = L" first ";
TCHAR* promptPtrs[] = {
const_cast<_TCHAR*>(L"\nSelect" + str + L"group: "),
const_cast<_TCHAR*>(L"\nRemove" + str + L"group: ")
};
str= L" second ";
but I got an error, I tried using wcscat_s but it's still new to me. i don't know What is the best way to implement it?
can you show me how to do it?
thank you!
Edit: I tried this code but the code still doesn't work!
//function concat all wchart
wchar_t* wcConcat(int i,int num, ...) {
va_list arguments;
va_start(arguments, i); // Initializing arguments to store all values after num
auto* str1= new wchar_t;
for (int x = 0; x < num; x++)
{
wchar_t* X = va_arg(arguments, wchar_t*); //
wcscat_s(str1,10, X);
} // Adds the next value in argument list to sum.
va_end(arguments); // Cleans up the list
return str1;
}
// my code became:
const wchar_t *str = L" first ";
TCHAR* promptPtrs[] = {
const_cast<_TCHAR*>(wcConcat(30,2,L" Select ",str, L"group: ")),
const_cast<_TCHAR*>(wcConcat(30,2,L" Remove ",str, L"group: ")),
};
Continue reading...
This is the code I am having
TCHAR* promptPtrs1[] = {
const_cast<_TCHAR*>(L"\nSelect first group: "),
const_cast<_TCHAR*>(L"\nRemove first group: ")
};
TCHAR* promptPtrs2[] = {
const_cast<_TCHAR*>(L"\nSelect second group: "),
const_cast<_TCHAR*>(L"\nRemove second group: ")
};
I want to change the code to like this
const wchar_t str[10] = L" first ";
TCHAR* promptPtrs[] = {
const_cast<_TCHAR*>(L"\nSelect" + str + L"group: "),
const_cast<_TCHAR*>(L"\nRemove" + str + L"group: ")
};
str= L" second ";
but I got an error, I tried using wcscat_s but it's still new to me. i don't know What is the best way to implement it?
can you show me how to do it?
thank you!
Edit: I tried this code but the code still doesn't work!
//function concat all wchart
wchar_t* wcConcat(int i,int num, ...) {
va_list arguments;
va_start(arguments, i); // Initializing arguments to store all values after num
auto* str1= new wchar_t;
for (int x = 0; x < num; x++)
{
wchar_t* X = va_arg(arguments, wchar_t*); //
wcscat_s(str1,10, X);
} // Adds the next value in argument list to sum.
va_end(arguments); // Cleans up the list
return str1;
}
// my code became:
const wchar_t *str = L" first ";
TCHAR* promptPtrs[] = {
const_cast<_TCHAR*>(wcConcat(30,2,L" Select ",str, L"group: ")),
const_cast<_TCHAR*>(wcConcat(30,2,L" Remove ",str, L"group: ")),
};
Continue reading...