Solution for Exercise 19-6
ex1906
#include <stdio.h>
int main()
{
int numbers[10];
int x;
int *pn;
pn = numbers; /* initialize pointer */
/* Fill array */
for(x=0;x<10;x++)
{
*pn=x+1;
pn++;
}
pn = numbers;
/* Display array */
for(x=0;x<10;x++)
{
printf("numbers[%d] = %d, address %p\n",
x+1,*pn,pn);
pn++;
}
return(0);
}
Notes
* The only difference between this code and the solution for Exercise 19-5 is the change from array notation numbers[x] to pointer notation *pn in Line 24.
Copyright © 1997-2025 by QPBC.
All rights reserved
