如何将双指针指向2d数组 [英] how assign double pointer to 2d array

查看:78
本文介绍了如何将双指针指向2d数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给我详细解释这个问题

推荐答案

请看我对这个问题的评论:目前还不清楚要解释什么。



但是,我的猜测是:你可以在这个提示之后解决问题:由于C和C ++数组的性质,2D数组与1D完全相同,像所有其他阵列一样的墙。引用具有两个或更多索引的数组元素的能力只不过是语法糖。请参阅: http://www.cplusplus.com/doc/tutorial/arrays [ ^ ]。



除其他事项外,请注意多维数组部分并找到最后,多维数组只是程序员的抽象......的地方。



另请参阅: http://en.wikipedia.org/wiki/Syntactic_sugar [ ^ ]。



然而,当它来到双指针,你可以使用稍微不同的东西,锯齿状数组

http://en.wikipedia.org/wiki/Jagged_array [ ^ ],

http://www.cplusplus.com/forum/general/69010 [ ^ ],

http://stackoverflow.com/questions/3904224/declaring-a-pointer-to-multidimensional-阵列和分配数组 [ ^ ]。



(无论如何,我不确定你的意思是什么?指针,指针指针或 double * :-)。)



你可能想要玩所有这一切,如果你不能得到什么就会问更具体的问题。



-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


By 如何将双指针分配给2D数组我假设你意思是,如何将指针指向双精度指定为双精度数组?



换句话说,如何指定指向某个元素的指针2D数组。



以下是指针和数组的示例声明。



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.

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.


这篇关于如何将双指针指向2d数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆