📄 subject_45572.htm
字号:
<p>
序号:45572 发表者:badboy 发表日期:2003-07-01 19:56:46
<br>主题:二维数组指针转换问题!!!各位大侠救命
<br>内容:我定义一个二维数组,int num[3][3]={1,2,3,4,5,6,7,8,9};<BR>我想把这个数组付给另外一个指针a, int ** a=num;<BR> 可是编译器给出错误提示如下:<BR><BR><BR>--------------------Configuration: fdfs - Win32 Debug--------------------<BR>Compiling...<BR>sss.cpp<BR>f:\张宁的文档\fdfs\sss.cpp(5) : <BR>error C2440: 'initializing' : cannot convert from 'int [3][3]' to 'int ** '<BR> Types pointed to are unrelated; conversion requires reinterpret_cast,<BR> C-style cast or function-style cast<BR>Error executing cl.exe.<BR><BR>fdfs.exe - 1 error(s), 0 warning(s)<BR><BR> 如果是一维数组肯定不会有此问题。比如, int num1[3]={1,2,3};<BR> 现在把这个数组付给另外一个指针 int * b=num1; 编译器不会报错。 请问各位大侠,为什么???<BR> 如果知道,请发帖子,或者发到我邮箱里 badboyhd@yeah.net<BR><BR> 看来,二维数组的的数组名不是指针,是吗?<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:_DAWN_ 回复日期:2003-07-01 20:15:58
<br>内容:二维数组的的数组名也是一级指针,不是二级指针。<BR>可以这样赋值 int *a=(int*)num;<BR>2003-7-1 20:18:49
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -