问题描述
大家好。
什么是Lvalue Required错误消息。
(这是什么意思?它是什么的缩写。)
我写了这个测试程序,我正在保留这条消息。
void main()
{
clrscr();
int(* x)[10];
(* x)=(int *)malloc(30 * sizeof(int ));
for(int i = 0; i< 5; i ++)
for(int j = 0; j< 6; j ++)
x [i] [j] = i * 10 + j;
for(i = 0; i< 5; i ++)
for( j = 0; j< 6; j ++)
printf("索引是%d%d,地址%d,有价值
%d \ n", i,j,& x [i] [j],x [i] [j]);
}
编译器是Turbo C for DOS(与Borland C ++相同的问题
Dos)。
请将您的答案通过电子邮件发送给以及后续消息
来自此消息。
访问* x在这里不正确。您需要访问其中一个索引,即
x [0]现在您正在访问左值
HTH
Allan
<<删除电子邮件的del>>
不,x是指向10 int数组的指针。你描述的类型将被编码为int * x [10];
很难。
<<删除电子邮件的del>>
Hi All.
What is The Lvalue Required error message.
(What does it mean?Is it an abbreviationof something.)
I wrote this test program and I am keeping geting this message.
void main()
{
clrscr();
int (*x)[10];
(*x)=(int *) malloc( 30 * sizeof (int) );
for(int i=0;i<5;i++)
for(int j=0;j<6;j++)
x[i][j]=i*10+j;
for(i=0;i<5;i++)
for(j=0;j<6;j++)
printf("The index is %d%d at address %d having value
%d\n",i,j,&x[i][j],x[i][j]);
}
The compiler is Turbo C for DOS(The same problem with Borland C++ for
Dos too).
Please e-mail your answers to en*********@gawab.com and as a follow-up
to this message.
accessing *x is incorrect here. You need to access one of the indices, i.e.
x[0] now you are accessing the lvalue
HTH
Allan
<<Remove the del for email>>
No, x is a pointer to an array of 10 int. The type you describe would
be coded as int *x[10];
Hardly. The C language requires *x and x[0] to be identical in
meaning.
HTH
Hardly.
<<Remove the del for email>>
这篇关于需要左值(奇怪)......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!