# Thread: How does it work?

1. ## How does it work?

Got this code to analyze.
Code:
```int i,m,*g_p;
int g[10]={1,5,3,4,0,22,8,0,-53,7};
main()
{
m=0;
g_p=g;
for (i=0;i<10;g_p++,m++,i++)
{
printf ("first loop: m=%d  *g_p=%d\n",m, *g_p);
printf ("\n");
for (;*g_p;g_p++,i++);
printf ("second loop: m=%d  *g_p=%d\n",m, *g_p);
printf ("\n");
}
printf ("end of program: m=%d  *g_p=%d\n",m, *g_p);
}```
Figured out that it calculates the numbers of series, delimited by 0. I don’t understand:
1. How does the pointer *g_p “jump” directly to 22 & then to -53.
2. Why does it get the value of 0?
3. What means the
Code:
`*g_p`
in
Code:
`    for (;*g_p;g_p++,i++);`
output:
first loop: m=0 *g_p=1

second loop: m=0 *g_p=0

first loop: m=1 *g_p=22

second loop: m=1 *g_p=0

first loop: m=2 *g_p=-53

second loop: m=2 *g_p=0

end of program: m=3 *g_p=0

2. The behaviour of the program is undefined.

Code:
`		for (;*g_p;g_p++,i++);`
to:
Code:
`		for (;*g_p;g_p++,i++) /* Do nothing */;`
and analyse what this loop is doing.

3. Did that with out further understanding.

Code:
`for (;*g_p;g_p++,i++);`
is equivalent to:
Code:
```while (*g_p != 0)
{
g_p++;
i++;
}```
Try running through the code step by step.

5. the style of that code looks ancient.

6. OK now all understood!