Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

CString behavior in VC6.0 and VS2010

$
0
0

Hi All,

I have observed the following behavior in “CString”. In VC 6.0  CString is a normal class  but in VS2010 “CString” is a Class Template(ATL::CString). There is some difference in the behavior of CString methods in VC 6.0 and VS2010. 

The concatenation (A =A+B) and operator overloading (A+=B) are behaving differently in VC6.0 and VS2010. I have created sample MFC project in VC6.0 and VS2010 to reproduce this issue.

Code:

CString strTemp = _T("");

       CString strVar1 = _T("");

       CString strVar2 = _T("");

       BYTE b[5] = { 0x12, 0x33, 0x00, 0x23, 0x22};

      for(int i=0;i<5;i++)

       {

              strTemp.Format("%c",b[i]);

              strVar1 += strTemp;

              strVar2 = strVar2 + strTemp;

       }

      int len1 = strVar1.GetLength();

      int len2 = strVar2.GetLength();

       AfxMessageBox(strVar1);

       AfxMessageBox(strVar2);

Observed Behavior:

CString behaviour in VC 6.0 and VS2010

Thanks,

Vijay


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>