1. ## pointer arrays!!!

i have a problem:

*p[5] means p[5][5]?

and i think i have to give a value to first pointer

how can i do it?

my last question is i have a 5x5 matrix how can i use this as a pointer *p[5] or *p[5][5]? and how can i give values to matrix?

2. ## Re: pointer arrays!!!

>*p[5] means p[5][5]?
No. The first is an array of 5 pointers. The second is a 2d array (5x5) of whatever type the variable is declared.
To complete the declarations:
>int *p[5];
>int p[5][5];
With the first you only get pointers to ints (5 of them).
With the second, you get a 5x5 *grid* of ints.

>and i think i have to give a value to first pointer
If you want to use it, you have to assign the pointer a value.

>how can i do it?
Code:
```#include <stdio.h>

int main(void)
{
int i;  /* one int */
int *p[5]; /* 5 pointers to ints */

p[0] = &i; /* assign the address of i to the first int pointer in the array */

i = 1; /* set i to 1 */
printf("i is %d\n", i);  /* show i */

*p[0] = 2;  /* change the data located at the address the pointer is pointing to */
printf("i is %d\n", i);  /* Show i again */
return (0);
}

Output:
i is 1
i is 2```
>my last question is i have a 5x5 matrix how can i use this as a pointer *p[5] or *p[5][5]? and how can i give values to matrix?
Have a look at this modified version of my first example:
Code:
```#include <stdio.h>

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

p[0] = &i[0];  /* can be simplified as p[0] = i; */

printf("i[0] is %d\n", i[0]);

*p[0] = 2;
printf("i[0] is now %d\n", i[0]);
return (0);
}```
This doesn't use all 5 element of the pointer array (p), it just shows how to use 1 element. You can expand on this in your own code.