本文介绍了指针和数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如何使用双指针访问二维数组。 即int a [3] [3]; int ** p; - - - - - 等 谢谢 Anthony 解决方案 int(* p)[sizeof * a / sizeof ** a] = a; - pete int(* p)[3]; 示例: #include< stdio .h> int main(无效) { int a [3] [3] = {{1, 2,3},{4,5,6},{7 ,8,9}}; int(* p)[3]; p = a; printf(" ; a [1] [1] =%d \ np [1] [1] =%d \ n, a [1] [1],p [1] [1] ); 返回0; } - Al Bowers Tampa,Fl USA mailto: xa ****** @ myrapidsys.com (删除x以发送电子邮件) http:// www。 geocities.com/abowers822/ 你不是。如果你想使用a的子数组(很少见),你需要一个指向数组的指针:int(* p)[3]。如果,OTOH,你想与各个int成员一起工作,你需要一个简单的int *。 声明int ** p意味着p是指针_to指针 int。你没有指向int的指针,所以你不应该使用 一个int **。 Richard How do you use a double pointer to access a two dimensional array.ie int a[3][3];int **p;-----etc.thanksAnthony 解决方案int (*p)[sizeof *a / sizeof **a] = a;--peteint (*p)[3];Example:#include <stdio.h>int main(void){int a[3][3] = {{1,2,3},{4,5,6},{7,8,9}};int (*p)[3];p = a;printf("a[1][1] = %d\np[1][1] = %d\n",a[1][1],p[1][1]);return 0;}--Al BowersTampa, Fl USAmailto: xa******@myrapidsys.com (remove the x to send email) http://www.geocities.com/abowers822/You don''t. If you want to work with the sub-arrays of a (which is rare),you need a pointer to an array: int (*p)[3]. If, OTOH, you want to workwith the individual int members, you need a simple int *.The declaration int ** p means that p is a pointer _to a pointer_ toint. You have no pointers to int to point at, so you should not be usingan int **.Richard 这篇关于指针和数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-05 05:43