为什么这是错的? [英] Why this is wrong?
问题描述
我有这段代码,
unsigned int input_0 [8];
* input_0 ++ = 100;
* input_0 ++ = 200;
* input_0 ++ = 300;
* input_0 ++ = 400;
* input_0 ++ = 1;
* input_0 ++ = 2;
* input_0 ++ = 3;
* input_0 = 4;
编译器是gcc移植到特定的嵌入式处理器。
编译器抱怨我不能使用这样的增量操作。
你知道为什么吗?
Hi,
I have this code,
unsigned int input_0[8];
*input_0++ = 100;
*input_0++ = 200;
*input_0++ = 300;
*input_0++ = 400;
*input_0++ = 1;
*input_0++ = 2;
*input_0++ = 3;
*input_0 = 4;
The compiler is gcc ported to a specific embedded processor. The
compiler complains that I can not use increment operation like that.
Do you know why?
推荐答案
2006年6月13日17:13:46 -0700
li ** ***@hotmail.com 写道:
On 13 Jun 2006 17:13:46 -0700
li*****@hotmail.com wrote:
我有这段代码,
unsigned int input_0 [8] ;
* input_0 ++ = 100;
* input_0 ++ = 200;
* input_0 ++ = 300;
* input_0 ++ = 400;
* input_0 ++ = 1;
* input_0 ++ = 2;
* input_0 ++ = 3;
* input_0 = 4;
编译器是gcc移植到特定的嵌入式处理器。
编译器抱怨我不能使用这样的增量操作。
你知道为什么吗?
Hi,
I have this code,
unsigned int input_0[8];
*input_0++ = 100;
*input_0++ = 200;
*input_0++ = 300;
*input_0++ = 400;
*input_0++ = 1;
*input_0++ = 2;
*input_0++ = 3;
*input_0 = 4;
The compiler is gcc ported to a specific embedded processor. The
compiler complains that I can not use increment operation like that.
Do you know why?
因为C标准并不是说它应该被允许。
Because the C standard doesn''t say it should be allowed.
在文章< 11 ******************** **@f14g2000cwb.googlegroups .com> ;,
< li ***** @ hotmail.com>写道:
In article <11**********************@f14g2000cwb.googlegroups .com>,
<li*****@hotmail.com> wrote:
unsigned int input_0 [8];
* input_0 ++ = 100;
unsigned int input_0[8];
*input_0++ = 100;
input_0是一个数组。你不能增加它。
但你可以设置指向数组开头的指针,然后增加
:
unsigned int * p =& input_0 [0]; / *或只是p =输入* /
* p ++ = 100;
...
- Richard
input_0 is an array. You can''t increment it.
But you can set a pointer to the start of the array and then increment
that:
unsigned int *p = &input_0[0]; /* or just p = input */
*p++ = 100;
...
-- Richard
2006年6月13日17:13:46 -0700, li ***** @ hotmail.com 在
comp.lang.c中写道:
On 13 Jun 2006 17:13:46 -0700, li*****@hotmail.com wrote in
comp.lang.c:
我有这段代码,
unsigned int input_0 [8];
* input_0 ++ = 100;
* input_0 ++ = 200;
* input_0 ++ = 300;
* input_0 ++ = 400;
* input_0 ++ = 1;
* input_0 ++ = 2;
* input_0 ++ = 3;
* input_0 = 4;
编译器是gcc移植到特定的嵌入式处理器。
编译器抱怨我不能使用这样的增量操作。
你知道为什么吗?
Hi,
I have this code,
unsigned int input_0[8];
*input_0++ = 100;
*input_0++ = 200;
*input_0++ = 300;
*input_0++ = 400;
*input_0++ = 1;
*input_0++ = 2;
*input_0++ = 3;
*input_0 = 4;
The compiler is gcc ported to a specific embedded processor. The
compiler complains that I can not use increment operation like that.
Do you know why?
因为input_0是一个数组,而不是指针,你不能增加数组。
数组不是指针,指针不是数组。很多
许多新手(和一些老朋友)从来没有抓住这个。
-
Jack Klein
主页: http://JK-Technology.Com
comp.lang.c的常见问题解答 http:// c- faq.com/
comp.lang.c ++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c ++
http://www.contrib.andrew.cmu。 edu /~a ... FAQ-acllc.html
Because input_0 is an array, not a pointer, and you cannot increment
an array.
An array is not a pointer, and a pointer is not an array. Far too
many newbies (and some oldbies) never grasp this.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
这篇关于为什么这是错的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!