I have a problem with understanding the use of pointers in my C-program. The program is designed to print out all elements in the array. The most confusing part is the for-loop that doesnt seem to make sense for me. What is the value of p from the beginning? How does the loop stop if the condition p < a + n always is true?
void element(int a[], int n)
{
for (int *p = a; p < a + n; p++)
printf("%d ", *p);
}
int main()
{
int f[5] = {1, 2, 3, 4, 5};
element(f, 5);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…