≡ Menu

What is an array of pointers. Explain with examples

You are Here: Home > Computer Subjects > Programming in C Language > …

What is an array of pointers. Explain with examples.

Ans. A pointer is a variable that contains the memory location of another variable. The values you assign to the pointers are memory addresses of other variables. We can assign pointers as an array of pointer with the following syntax:

 data_type *pointer_name[size]

Example

     main()
     {
          int *arr[2];
          int a = 3, b = 5;
          int i;

          arr[0] = &a;
          arr[1] = &b;

          for (i=0; i< 2; i++)
          {
                  printf("The value of %d= %d ,address is %u\t \n", i, *(arr[i]),arr[i]);
          }

          return 0;
     }

Click Here to Find Latest Jobs and Current Affairs
{ 1 comment… add one }
  • Thanga Kumar November 15, 2012, 3:36 pm

    thank u for the help

Leave a Comment