Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>while(*ptr++) </code></pre> <p>will keep going till the time ptr does not point to the end of this string which is <code>\0</code> (Null Terminator) , This same statement also increments ptr to point to next value on each run, so essentially its saying <code>while this condition is true</code>, keep going. And the condition is <code>while ptr still points to an element of arr</code>;</p> <blockquote> <p>In C++, the definition of NULL is 0, so there is only an aesthetic difference. I prefer to avoid macros, so I use 0. Another problem with NULL is that people sometimes mistakenly believe that it is different from 0 and/or not an integer. In pre-standard code, NULL was/is sometimes defined to something unsuitable and therefore had/has to be avoided. That's less common these days.</p> </blockquote> <p><strong><a href="http://www.stroustrup.com/bs_faq2.html#null" rel="nofollow">Reference</a></strong></p> <p><strong>Edit:</strong></p> <blockquote> <p>But why is it accepting arguments like: while('x')? A letter 'x' is true?</p> </blockquote> <p>No it doesn't mean the letter itself is true, it means that its not NULL, which is 0. Consider it like this. </p> <pre><code>while('x') </code></pre> <p>is the equivalent of saying</p> <pre><code>while('x'!=0) // so that is perfectly acceptable and understandable </code></pre> <p><strong>Edit 2:</strong></p> <p>Here is a simpler example for you to be able to better understand</p> <pre><code>#include &lt;iostream&gt; int main() { int x=0; if(x) { cout&lt;&lt;"If this is shown, x was not 0."; } if(x==0) { cout&lt;&lt;"so does it mean x is true? no: It means your condition 'x==0' is true"; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload