Groups
Groups
Sign in
Groups
Groups
Linux C/C++/系统编程 一站式学习
Conversations
About
Send feedback
Help
如何定义一个“指向指针数组的指针数组”,不用typedef
41 views
Skip to first unread message
not.using pc
unread,
Dec 10, 2013, 4:18:55 AM
12/10/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to learning-l...@googlegroups.com
int *a[10] ——a是数组,包含10个int *
int (*a)[10]——a是指针,指向int[10]
那么“一个数组,每个元素是指向int[10]的指针”怎么写?不用typedef。
M$ VS2013里,
用typedef可以这么写:
typedef int(*a_t)[10];
a_t a[10];
int (*b)[10];
a[0] = b;
不用typedef怎么写?在网上搜索没有很好的答案。
int ((*a)[10])[10]报错。应该没必要用GCC试了。
weinan003
unread,
Dec 10, 2013, 5:02:13 AM
12/10/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to learning-linux-c-cpp
int *a[10]就行了,你这个数组里面已经是十个int型的指针了,你只需要将这十个指针指向一个int【10】的数组就可以了
如
for(int i = 0;i < 10;i ++)
{
a[i] = (int *)malloc(sizeof(int) * 10)
}
C不直接支持间接寻址,如果你想搞诸如指针的指针,只能自己动手敲出相应的代码即可
weinan003
发件人:
not.using pc
发送时间:
2013-12-10 17:18
收件人:
learning-linux-c-cpp
主题:
[learn-linux-c-cpp] 如何定义一个“指向指针数组的指针数组”,不用typedef
--
您收到此邮件是因为您订阅了 Google 网上论坛的“Linux C/C++/系统编程 一站式学习”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到
learning-linux-c...@googlegroups.com
。
要查看更多选项,请访问
https://groups.google.com/groups/opt_out。
not.using pc
unread,
Dec 10, 2013, 7:28:48 AM
12/10/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to learning-l...@googlegroups.com, weinan003
我的意思是不仅仅是要指向正确的位置,我还需要指针的类型正确,也就是数组中的指针++能往后+(元素大小)*(数组大小)。你的解决方案指向是正确的,但是无法对指针正确++。
Reply all
Reply to author
Forward
0 new messages