當前位置:編程學習大全網 - 網站源碼 - 如何判斷CString對象是否為空

如何判斷CString對象是否為空

CString str1 = "VC源碼網";

if(str1 != NULL)

{

AfxMessageBox("str1為空");

}

esle

{

AfxMessageBox("str1不為空");

}

因為str1它是壹個CString對象,而不是壹個指針,將壹個對象和NULL指針做比較顯然是不合適的。

有朋友要問,出了IsEmpty()函數,還有沒有其他方法判斷CString字符串為空呢?有,我們介紹壹個效率較低的方法:

CString str1 = "VC源碼網";

if (x != "")

{

AfxMessageBox("str1不為空");

}

else

{

AfxMessageBox("str1為空");

}

  • 上一篇:phpstudy_pro怎麽改回默認密碼
  • 下一篇:啥叫源碼
  • copyright 2024編程學習大全網