Thursday, November 26, 2020

ARRAY OF POINTERS

An array of pointers can be declared very easily.

int *p[10];

This declares an array of 10 pointers, each of which points to an integer.

Ex:

int* p[10];

int a = 10, b = 20, c = 30;

p[0] = &a;

p[1] = &b;

p[2] = &c;


In general, an array of pointers can be used to point to an array of data items, with each element of
the pointer array pointing to an element of the data array. Data items can be accessed either directly in the data array, or indirectly by dereferencing the elements of the pointer array. The advantage of an array of pointers is that the pointers can be reordered in any manner without moving the data items.

For example, thepointer array can be reordered so that the successive elements of the pointer array point to data items in a sorted order without moving the data items.

0 comments:

Post a Comment

Data Structures with C++



NET/SET/CS PG



Operating Systems



Computer Networks



JAVA



Design and Analysis of Algorithms



Programming in C++

Top