Code:
CString ls;
ls.Format("%d",bufferLenght);
In case you get hit by this problem again in future, you better write it this way:
Code:
CString ls;
ls.Format( _T("%d"),bufferLenght);
// - OR-  (If project is always Unicode (See 'L')
ls.Format(L"%d",bufferLenght);
You may like to read this:What is TCHAR