stephencushen
asked on
cstring = string
Simple question!
i have a string myString = "01010110";
i need to convert the string into a cstring myCSting
i thought you could say myCString = mystring.
But this throws up a conversion error.
what the best way to get around this error?
i have a string myString = "01010110";
i need to convert the string into a cstring myCSting
i thought you could say myCString = mystring.
But this throws up a conversion error.
what the best way to get around this error?
ASKER
the code is as follows
void CMFCCalculatorDlg::OnDecRa dio()
{
string binaryValue = decObj.getBinaryValue();
CString m_edit = binaryValue;
UpdateData(FALSE);
}
that was the code that produces the error.
void CMFCCalculatorDlg::OnDecRa
{
string binaryValue = decObj.getBinaryValue();
CString m_edit = binaryValue;
UpdateData(FALSE);
}
that was the code that produces the error.
ASKER
the code is as follows
void CMFCCalculatorDlg::OnDecRa dio()
{
string binaryValue = decObj.getBinaryValue();
CString m_edit = binaryValue;
UpdateData(FALSE);
}
that was the code that produces the error.
void CMFCCalculatorDlg::OnDecRa
{
string binaryValue = decObj.getBinaryValue();
CString m_edit = binaryValue;
UpdateData(FALSE);
}
that was the code that produces the error.
I assume string is:
typedef unsigned char* string;
try:
CString m_edit(binaryValue);
Jim
typedef unsigned char* string;
try:
CString m_edit(binaryValue);
Jim
ASKER
no im not using a typedef.
im using the string data type. i include "#include <string>" at the top of the prog.
im using the string data type. i include "#include <string>" at the top of the prog.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or
CString m_edit(binaryValue.c_str() );
You need to use the c_str() member function to pass the const char* pointer to CString object.
CString m_edit(binaryValue.c_str()
You need to use the c_str() member function to pass the const char* pointer to CString object.
oh, string is from the STL.
Then Axter's solution is the right answer.
I wasn't sure where string came from - sorry.
JB
Then Axter's solution is the right answer.
I wasn't sure where string came from - sorry.
JB
I performed the following test with success:
char sz[] = "hello";
CString s;
s = sz;
How is myString defined?
Jim