I have a problem where I am reading a string value from data file through my Record Set into basic string and then trying to convert it into LPCSTR or say LPSTR and where I am getting into trouble.
The record set that i used is as follows:
The sample code that I used in my program is as below:
RecordSet * rst;
rst = m_ptDBRecords->GetActiveRecordSet();
if(rst != NULL)
sJobNumber = string(rst.Value); // sJobNumber is std::string
psJobNumber = sJobNumber.c_str(); // psJobNumber is LPCSTR
If you see the first line inside the curly braces, i am converting Value read from recordset into basic string and storing it into sJobNumber.
In the second line the RHS of equal sign statement converts basic string into const char* using c_str() then store the value into psJobNumber. Actually as per the code it has to give me the final value in psJobNumber, but it is coming out of the brace when control reaches the second line.
Please give me information about the followings:
1. Conversion of basic string to LPSTR
2. Conversion of basic string to LPCSTR
3. Conversion of TCHAR* to LPSTR or LPCSTR
Your help will be greately appriciated.