JOINT STRIKE FLGHTER, AIR VEHICLE, C++ CODING STANDARDS Chapter 4.23 Type Conversions, AV Rule 182.
How can the conversion be successful?
JOINT STRIKE FLGHTER, AIR VEHICLE, C++ CODING STANDARDS Chapter 4.23 Type Conversions, AV Rule 182.
How can the conversion be successful?
I do not think that making a CString from 'const CHAR'* represents a conversion in terms of the the AV Rule.
Pass the const char* pointer to the narrow string to the CString class constructor.
For example,
LPCTSTR psz = "narrow string";
CString str(psz); // Construct CString object
printf_s("Null terminated string : %s\n", psz);
printf_s(("CString object : %s\n"), str.GetString());
Another way to construct the CString object-
CString str = psz; // Construct CString object
This is the result of checking the code using the c/c++ test tool from parasoft, a reliability test tool company.
The project is set to multibyte.
void foo2(CString strPath)
{
//strPath
}
void foo(LPCTSTR strPath)
{
foo2(CString(strPath)); << this line
}
8 people are following this question.