char[] to CString conversion
-
char str[200]; GetData(str); CString sTemp = str; the CString assignment works fine here if first character of str is not empty. If str[0] ='' str[1] = 'a' etc... then after assignment sTemp contains empty string why?
The constructor of
CString
only reads till the empty character, that's why. You can however doCopyMemory(sTemp.GetBuffer(count), str, count);
sTemp.ReleaseBuffer(count);«_Superman_» I love work. It gives me something to do between weekends.
-
char str[200]; GetData(str); CString sTemp = str; the CString assignment works fine here if first character of str is not empty. If str[0] ='' str[1] = 'a' etc... then after assignment sTemp contains empty string why?
KASR1 wrote:
str[0] =''
What do you mean with the above (i.e. it is NOT a valid statement, you know)? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
char str[200]; GetData(str); CString sTemp = str; the CString assignment works fine here if first character of str is not empty. If str[0] ='' str[1] = 'a' etc... then after assignment sTemp contains empty string why?