indexing an integer pointer in C++
<p>I'm a beginner in C++ and trying to get my head around every new concept I come across by writting as many various little programs (programmlets) as possible. 
So I've just concocted the following piece of code:</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int main(){
int inumbers[] = {1 ,2 , 3, 4, 5};
int *p;
int i;

p = inumbers;

for(i = 0; p[i]; i++) cout &lt;&lt; p[i] &lt;&lt; '\n';

return 0;

}
</code></pre>

<p>And I fail to understand a seemingly simple thing: how does a compiler "know" when to stop incrementing the loop variable "i"? Surprisingly, the code does work the way it was supposed to.</p>