(To whom who may mark this as duplicate:
I have seen Convert CString to const char* which returns the sam error when I use this macro:
CT2A ascii(m_InstrumentName, CP_UTF8);
TRACE(_T("UTF8: %S\n"), ascii.m_psz);
that I don't know how this works
and Problem: How to convert CString into const char * in C++ MFC (it returns error C2440: 'type cast' : cannot convert from 'CString' to 'LPCSTR' ) )
I have a code that gives me this error:
Error 6 error C2664: 'void CElliotEngineDoc::ExportFile(CFile *,const char *)' : cannot convert argument 2 from 'CString' to 'const char *'
It's not my code, and it was written in VC 8.0 and I'm using VC 12.0
Here are the parts that the function is defined and is called.
Could you please tell me what would be the problem?
The function that is called:
void CElliotEngineDoc::ExportFile(CFile* fp, const char* isin)
{
CString s = "time;isin;high;low;last;vol$;open\r\n";
fp->Write(s, s.GetLength());
char buf[100];
PriceNodeVec::const_iterator it = m_PriceNodes.begin();
while (it != m_PriceNodes.end())
{
const PriceNode& n = *it++;
sprintf(buf, "%s;%s;%g;%g;%g;%g;%g\r\n",
n.date.Format("%Y%m%d"),
isin,
n.high,
n.low,
n.price,
n.volume,
n.close );
fp->Write(buf, strlen(buf));
} // while
}
here is the definition of CString (if I'm not wrong):
typedef ATL::CStringT< wchar_t, StrTraitMFC_DLL< wchar_t > > CStringW;
typedef ATL::CStringT< char, StrTraitMFC_DLL< char > > CStringA;
typedef ATL::CStringT< TCHAR, StrTraitMFC_DLL< TCHAR > > CString;
And m_InstrumentName is defined like this:
CString m_InstrumentName;
And the error is in this line:
ExportFile(ar.GetFile(), m_InstrumentName);