Click here to Skip to main content
15,997,509 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
give me detail explanation of this question
Posted
Comments
Sergey Alexandrovich Kryukov 23-Jan-15 14:19pm    
Not clear what your problem is. It looks like you are somehow confused with those double pointer.
—SA

Please see my comment to the question: it's not quite clear what to explain.

However, my guess is: you will be able to sort things out after this hint: due to the nature of C and C++ array, "2D" array is exactly the same way as "1D", as wall as all other array ranks. The ability to reference array elements with two or more indices is nothing but syntactic sugar. Please see: http://www.cplusplus.com/doc/tutorial/arrays[^].

Among other things, pay attention for the section "Multidimensional arrays" and find the place saying "At the end, multidimensional arrays are just an abstraction for programmers…".

See also: http://en.wikipedia.org/wiki/Syntactic_sugar[^].

However, when it comes to "double pointers", you can use slightly different thing, jagged arrays:
http://en.wikipedia.org/wiki/Jagged_array[^],
http://www.cplusplus.com/forum/general/69010[^],
http://stackoverflow.com/questions/3904224/declaring-a-pointer-to-multidimensional-array-and-allocating-the-array[^].

(Anyway, I am not sure what did you mean by "double pointer", a pointer to pointer or double* :-).)

You may want to play with all this and ask more specific questions if you cannot get something.

—SA
 
Share this answer
 
v2
Comments
CPallini 23-Jan-15 17:33pm    
5.
Sergey Alexandrovich Kryukov 23-Jan-15 18:54pm    
Thank you, Carlo.
—SA
By "how assign double pointer to 2D array" I assume you mean, "how to assign a pointer-to-double to a 2D array of double?"

In other words, how to assign a pointer to some element in the 2D array.

Here are example declarations for pointer and array.

C++
double *pointer;
double array[4][4];

// Assign to element at row 1, column 2.

double *pointer = &array[1][2];

// Note that these two do the same thing.

double *pointer = array[3];

double *pointer = &array[3][0];


If by "double pointer" you mean "pointer to pointer", you will need to update your question to make it more clear.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900