[Error] lvalue required as left operand of assignment
用的是DEVc++,想要用指针的方式实现对二维数组s中元素s[2][7]赋值为A
#include <stdio.h>
main()
{
char s
[3][10],*p
;
p
=&s
[2][7];
*p
='A';
printf("%c",s
[2][7]);
}
可以得出正确结果 但是按照书上的方法编写就会出错,一共三种方法,每种错误都不一样。
#include <stdio.h>
main()
{
char s
[3][10],*p
;
p
=s
[0];
(*(p
+2)+7)='A';
printf("%c",s
[2][7]);
}
#include <stdio.h>
main()
{
char s
[3][10],*p
;
p
=s
[0];
p
[2][7]='A';
printf("%c",s
[2][7]);
}
#include <stdio.h>
main()
{
char s
[3][10],*p
;
p
=s
[0];
(*(p
+2)[7])='A';
printf("%c",s
[2][7]);
}
有人知道原因吗