I have a CString variable that i a need to convert to LPCTSTR(const char*) .I need this conversion so that i can use it as an argument in a function .
The CString look like :
CString sqlTemp = _T("INSERT INTO "+ sw1 +" (filename, "+ sw2 +") VALUE ("+ sw7 +","+ sw3 +" ) ");
It contains an query. The prototype of the function is :
int WriteBlob(LPCTSTR szSqlStat, LPCTSTR szFilePath)
So could you show me an exemple of how to convert to LPCTSTR ? It may be trivial but i am a c++ beginner and i still get a hang of it.
Thanks .
Solution 4. CString p; m_editbox->GetWindowText(p); CWND *c = FindWindow(NULL,p);
For example, the macro to convert CString to LPCWSTR is CT2W(s) . Another way is to use the specialized CStringA and CStringW classes. These are the corresponding ascii and wide versions of CString depending on if you're compile with the UNICODE flag.
CString pi = "3.14"; return _ttof(pi); Reading a string value and parse/convert it to float allows you to locate the error when there is one. All you need is a help of a C Run-time function: strtod() or atof().
An LPCSTR is a 32-bit pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters.
One method of conversion is like this:
CString str;
str = "Hello";
LPCSTR szTemp = (LPCSTR)(LPCTSTR)str;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With