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

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -