How to convert int variable and append to const wchar_t*

Master James

I need a final query like this:
const wchar_t *fin = L"UPDATE info SET status = 'closed' where age = '12'";

If the function receives a value I want to append something like this:
const wchar_t *fin = L"UPDATE info SET status = 'closed' where age = " + convertedAge;

Here is my update function code:

void updateDB(int passAge){
   std::wstring myString;
   convertedAge= std::to_wstring(passAge);
   const wchar_t* fin = L"UPDATE info SET status = 'closed' where age = " + convertedAge;
}

How to convert that integer variable in order append that one in const wchar_t*and act as a single query?

DeiDei

The C++ standard string class includes a .c_str() function just for such situations.

void updateDB(int passAge){
   std::wstring myString = L"UPDATE info SET status = 'closed' where age = '" 
                        + std::to_wstring(passAge) + L"'";
   const wchar_t* fin = convertedAge.c_str();
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Convert const wchar_t* into a WCHAR*

Convert const char* to const wchar_t*

Convert LOWORD(wParam) to const wchar_t*

Convert const wchar_t* to LPWSTR

cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}'

How to convert char to wchar_t*?

How to convert std::string to wchar_t*

How convert LPCWSTR to wchar_t*?

How could I assign the value from lua_tostring() to a variable in type of wstring or const wchar_t* in utf-8

How to use regex_iterator with const char/wchar_t*?

How to transform const wchar_t type to LPTSTR (C++)

How to make concatenations at const wchar_t* parameters?

cannot convert argument 1 from 'ATL::CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>' to 'const char *'

How to convert Python list of strings into C array of wchar_t?

How do I convert wchar_t* to string?

How to copy/convert a char string to a wchar_t string in C?

Is " const wchar_t* " a pointer?

format wstring with fmt fails: no matching function for call to 'format(const wchar_t [17], int)'

Cannot convert parameter 1 from 'const wchar_t *' to 'LPCTSTR' in MFC / C++ project

"cannot convert 'wchar_t*' to 'LPCSTR' {aka 'const char*'}gcc" when trying to use WriteConsoleOutputCharacter()

How to properly initialize a const int const * variable?

How to fix " State Error (active) E0513 a value of type “const wchar_t *” cannot be assigned to an entity of type “wchar_t *”"

win32 atoi issue which can't convert argument 1 from 'wchar_t [5]' to 'const char *

Make a condition on const wchar_t*

GETTING THE ERROR IN VISUAL STUDIO: error C2664: '_chmod' : cannot convert parameter 1 from 'wchar_t [260]' to 'const char *'

How to convert from "universal character name" to a sequence of wchar_t's?

c++ How to read a wchar_t* to into a std::wsting variable and print in HEX

Convert Swift String to wchar_t

Cannot convert 'wchar_t' to 'LPCSTR'