I have a code in which Cstring and wchar_t both are used. I think i can do the same work with wchar_t instead of Cstring, so why to use Cstring.
in m_szChargeType and m_szConfirmedChargeType i have A.
At first my code was
wchar_t m_szChargeType[LEN_CHARGE_TYPE];
wchar_t m_szConfirmedChargeType[LEN_CHARGE_TYPE];
LoadString(GetResourceInstance(),IDS_MS_CI_TYPEA,m_szChargeType,LEN_CHARGE_TYPE);// fills value A in m_szChargeType
LoadString(GetResourceInstance(),IDS_MS_CI_TYPEA,m_szConfirmedChargeType,LEN_CHARGE_TYPE); // fills value A in m_szConfirmedChargeType
CString strSpace(IDS_MS_SPACE); //IDS_MS_SPACE has a space in rc file and IDS_MS_TYPE have rate in ini file
CString strType(IDS_MS_TYPE);
strSpace += strType;
wsprintf(m_szChargeType, _T("%s%s"), m_szChargeType, strSpace);
wsprintf(m_szConfirmedChargeType, _T("%s%s"), m_szConfirmedChargeType, strSpace);
the result in m_szChargeType and m_szConfirmedChargeType was A0, but expected was A Rate
then i did
wchar_t strSpace[LEN_CHARGE_TYPE];
wchar_t strType[LEN_CHARGE_TYPE];
LoadString(GetResourceInstance(),IDS_MS_SPACE,strSpace,LEN_CHARGE_TYPE);
LoadString(GetResourceInstance(),IDS_MS_TYPE,strType,LEN_CHARGE_TYPE);
wsprintf(m_szChargeType, _T("%s%s%s"), m_szChargeType, strSpace, strType);
wsprintf(m_szConfirmedChargeType, _T("%s%s%s"), m_szConfirmedChargeType, strSpace, strType);
it worked fine. and the output was same as expected A RATE
CStringis a class, and so it provides functionality.wchar_tis just a basic type, and it represents a single wide character. I’m assuming you were talking aboutwchar_t*.It’s like asking why you should use
std::stringoverchar*.