这个表达是非法的吗? [英] Is this expression illegal?
问题描述
我想将一个双恶魔数组分配给一个int **指针,
但gcc给出错误!
>
int env [11] [11];
int ** e = env;
怎么做?
Hi,
I want to assign a two-demon array to a int ** pointer,
but gcc give an error!
int env[11][11] ;
int ** e = env ;
How to do this?
推荐答案
" Bo Yang" < st ****** @ mail.nankai.edu.cn写信息
新闻:el ********** @ news.cn99.com ...
"Bo Yang" <st******@mail.nankai.edu.cnwrote in message
news:el**********@news.cn99.com...
我想将一个双恶魔数组分配给一个int **指针,
但是gcc给出错误!
int env [11] [11];
int ** e = env;
如何做到这一点?
Hi,
I want to assign a two-demon array to a int ** pointer,
but gcc give an error!
int env[11][11] ;
int ** e = env ;
How to do this?
int env [11] [11]是一个二维的整数数组。数据是int值。
int **是指向int指针的指针。数据将包含指针。
int * e = env;
就是你想要的。它是一个指向int的指针,可以作为
数组访问。
e [10]是合法的。
如果您的下一个问题是,如何从
e中找出如何访问env [5] [5],通用公式为:
row * rowsize +列。
所以它将是
e [5 * 11 + 5];
int env[11][11] is a two dimentional array of ints. The data is int values.
int** is a pointer to an int pointer. The data would contain pointers.
int* e = env;
is what you want. It is a pointer to an int and can be accessed as an
array.
e[10] is legal.
If your next question is, how do you figure out how to access env[5][5] from
e, the general formula is:
row * rowsize + column.
so it would be
e[5 * 11 + 5];
Jim Langston:
Jim Langston :
" Bo Yang" < st ****** @ mail.nankai.edu.cn写信息
新闻:el ********** @ news.cn99.com ...
"Bo Yang" <st******@mail.nankai.edu.cnwrote in message
news:el**********@news.cn99.com...
>
我想将一个双恶魔数组分配给一个int **指针,
但是gcc会出错! br />
int env [11] [11];
int ** e = env;
如何做到这一点?
>Hi,
I want to assign a two-demon array to a int ** pointer,
but gcc give an error!
int env[11][11] ;
int ** e = env ;
How to do this?
int env [11] [11]是一个二维数组的整数。数据是int值。
int **是指向int指针的指针。数据将包含指针。
int * e = env;
就是你想要的。它是一个指向int的指针,可以作为
数组访问。
e [10]是合法的。
如果您的下一个问题是,如何从
e中找出如何访问env [5] [5],通用公式为:
row * rowsize +列。
所以它将是
e [5 * 11 + 5];
int env[11][11] is a two dimentional array of ints. The data is int values.
int** is a pointer to an int pointer. The data would contain pointers.
int* e = env;
is what you want. It is a pointer to an int and can be accessed as an
array.
e[10] is legal.
If your next question is, how do you figure out how to access env[5][5] from
e, the general formula is:
row * rowsize + column.
so it would be
e[5 * 11 + 5];
但我会如果我做了另一个错误
e [1] [1]
怎么避免这个?我不想写每次只需[1 * 11 + 1] $
谢谢!
But I will get another error if I do
e[1][1]
how to avoid this? I don''t want to write
e[1*11+1] every time!
Thank you!
Bo Yang写道:
Bo Yang wrote:
我想将一个双恶魔数组分配给一个int **指针,
但是gcc给出错误!
int env [11] [11];
int ** e =环境;
如何做到这一点?
Hi,
I want to assign a two-demon array to a int ** pointer,
but gcc give an error!
int env[11][11] ;
int ** e = env ;
How to do this?
int * e [11] = env;
-
- Pete
Roundhouse Consulting,Ltd。( www.versatilecoding.com )
标准C ++库扩展:教程和
参考的作者。 ( www.petebecker.com/tr1book )
这篇关于这个表达是非法的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!