| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1492 人关注过本帖
标题:[求助]c++ syntax about 2d array
只看楼主 加入收藏
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
以下是引用HJin在2007-6-22 23:38:58的发言:
野比's way

[CODE]int* b=&a[0][0]; //a pointer to the start of the array
int** c=&b; //a pointer points to the pointer which points to the array... wow.....tongue twister... (^^!)
//now you can use the c pointer as the parameter of f() instead...[/CODE]

on my system gives access violation error. b points to the start of the 2d array, c is just the address of the b variable, so that

[CODE]c[2][2] = 1;[/CODE]
fails.




I think you misunderstand.
int *p[n];
p[n] = &a[0][0]
……

then
int **ptr = p;

try this.


Fight  to win  or  die...
2007-06-22 23:46
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 
以下是引用HJin在2007-6-22 23:38:58的发言:
野比's way

[CODE]int* b=&a[0][0]; //a pointer to the start of the array
int** c=&b; //a pointer points to the pointer which points to the array... wow.....tongue twister... (^^!)
//now you can use the c pointer as the parameter of f() instead...[/CODE]

on my system gives access violation error. b points to the start of the 2d array, c is just the address of the b variable, so that

[CODE]c[2][2] = 1;[/CODE]
fails.

Hey budy, I posted a new method on the 7th floor.. SEE ?

Take a look..


女侠,约吗?
2007-06-24 23:10
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
得分:0 
thanks 野比 and aipb2007, got your guys' idea.

I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-06-25 01:54
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 
Not at all...

女侠,约吗?
2007-06-25 19:51
快速回复:[求助]c++ syntax about 2d array
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.106607 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved