Why use a Pointer and its dereference in if statement in c++ -


i looking c++ code, , confused if(ptr && *ptr), in case?

// process data here.  break data separate pieces ,  // display sake of simplicity. char * a_pszbreak = null; char * a_pszdataitem = (char*)s_aucdatabuffer; {     // poll data terminated either carriage return alone, or     // carriage return/line feed pair.     a_pszbreak = strpbrk(a_pszdataitem, "\n\r");     if (a_pszbreak && *a_pszbreak)     {         *a_pszbreak = 0;         a_pszbreak++;         logpolldata((const char *)a_pszdataitem);     }     a_pszdataitem = a_pszbreak; } while (a_pszbreak && *a_pszbreak); 

it means pointer should point , in addition must different 0.

it's (a_pszbreak != nullptr && a_pszbrealk[0] != '\0')


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -