2014年8月28日 星期四

C++ 判斷字串是否為空,NULL,和如何判斷函數傳遞後的位置 ( Determine string or char is null or "" and function send variables locations how to determine is it null or "" use c++ )

字串要判斷是否為  = "" ?
If you want determine string or char is ""

你可以用這樣
You can use that:
--------------------------------------------------------------
#include <string>

std:: string szExpr = "";

if (szExpr=""){}

---------------------------------------------------------------

也可以
You can use it to ,May be you can search empty() c++
--------------------------------------------------------------
#include<string>
std::string szExpr = "";
if(szExpr.empty()){}
---------------------------------------------------------------

************************************************
但是我們要怎麼判斷,如果我們是傳送位置的話
(甚麼式位置 你可以印看看 例如:000000014029A838 )
But how can we determine  ,if we in function we get the location 000000014029A838
So how to determine the function locations ?
我們可以測試一下
try it!!
-------------------------------------------------------------------------

 CMapEngin::Select(LPCTSTR szTable)

{
if(*szTable){}
std::cout << *szTable ;

}
--------------------------------------------------------------------------
但是我們也可以把地址變成 字串後用先前的例子
And we can change locations to string then use first example



ps(This is error examples):

bad1.

I tried szExpr == NULL , But it can't .

bad 2.
if (szExpr == '\0'){}




沒有留言:

張貼留言