how to do it?

0 Gurpreet Singh · July 4, 2015

i am trying to create a pointer which points to the address of the 1st element of a pointer array( int *x[ ] ).

Post a Reply

Replies

Oldest  Newest  Rating
0 c student · July 5, 2015
edited
0 Gurpreet Singh · July 5, 2015
sorry but i don't think your answer is right.
array [0] is a pointer and ptr pointer is equal to array [0] , so ptr and array [0] is same and i required ptr to point to the address of array [0].
so simply what we can do is equate ptr to address of array [0] but that is giving an error.

if you think that you are right then you can check your answer by printing ptr and array [0].
they would give the same address.
0 c student · July 4, 2015
int main() {
    int *array[5];
    int **ptr = array; // array == &array[0]
    
    return 0;
}
  • 1

C++

107,332 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator