user1118764
user1118764

Reputation: 9845

CString IsEmpty keeps returning true

For some reason CString IsEmpty keeps returning true even though the CString is obviously not empty.

CString temp = "Hello";
if (temp.IsEmpty)
  AfxMessageBox("temp is empty");
else
  AfxMessageBox("temp is not empty");

Any reason why this is the case?

Upvotes: 1

Views: 2135

Answers (2)

milet
milet

Reputation: 91

Perhaps:

if(temp.IsEmpty())

not

if(temp.IsEmpty)

Upvotes: 2

Leandro Rodriguez
Leandro Rodriguez

Reputation: 1

Iam not totally sure but try this:

CString temp( "Hello" );

I found in this link https://msdn.microsoft.com/en-us/library/aa314317%28v=vs.60%29.aspx Look at the end, it says

CString city = "Philadelphia"; // NOT the assignment operator

Hope this helps!:)

Upvotes: 0

Related Questions