有效的C语法。 [英] Valid C syntax.
问题描述
这是有效的C语句。
int a,b,c;
c = 5;
< <<
a = b = c;
Is this the valid C statement.
int a,b,c;
c = 5;
<<<
a = b = c;
>>>
>>>
任何人都可以对此有所了解。
-Paresh
Can anyone throw the light on this.
-Paresh
推荐答案
嗨
On Fri,2008年11月21日03:05:21 -0800,paresh写道:
Hi
On Fri, 21 Nov 2008 03:05:21 -0800, paresh wrote:
这是有效的C语句。
int a,b,c;
c = 5;
<<<
a = b = c;
Is this the valid C statement.
int a,b,c;
c = 5;
<<<
a = b = c;
>>
>>
编号>>是一个解析错误。
No. >>is a parse error.
任何人都可以对此有所了解。
Can anyone throw the light on this.
它是某种差异的输出吗?
viza
Is it the output of some kind of diff?
viza
>
11月21日,11:05,paresh< pareshvarsh ... @ gmail.comwrote:
On 21 Nov, 11:05, paresh <pareshvarsh...@gmail.comwrote:
这是有效的C语句。
int * a,b,c;
c = 5;
<<<
a = b = * c;
任何人都可以对此有所了解。
Is this the valid C statement.
int *a,b,c;
c = 5;
<<<
a = b = *c;
Can anyone throw the light on this.
目前还不清楚你在问什么。什么是这个?
1.声明和上述两个声明不是有效的
声明。
他们是几个声明。
2."<<<""是语法错误
3.a = b = c;是一个有效的声明。为什么不是?
注意分配(" =")从右到左评估所以上面的
将c分配给b给出一个结果等于新的b,然后分配给a。
-
Nick Keighley
it is unclear what you are asking. What is "this"?
1. the declaration and two statements above are not "a valid
statment".
They are several statments.
2. "<<<" is a syntax error
3. "a = b = c;" is a valid statement. Why wouldn''t it be?
Note assignment ("=") evaluates right to left so the above
assigns c to b giving a result equal to the new b which is
then assigned to a.
--
Nick Keighley
paresh< pa ************ @ gmail.comwrites:
paresh <pa************@gmail.comwrites:
这是有效的C语句。
int a,b,c;
c = 5;
<< <
a = b = c;
Is this the valid C statement.
int a,b,c;
c = 5;
<<<
a = b = c;
>>>>
>>>>
任何人都可以对此有所了解。
Can anyone throw the light on this.
假设<<<<<<<<<<<"和>>>"只是在那里标记你的b / b
当时要问的是,是的,它是有效的。 a和b都被分配了
c的值。
它被解析为'a =(b = c);''。右边b = c的结果是b / b
分配后的b值,它是分配给a的
值(在任何转换之后) )。当a,b和c的类型不同时,这最重要的是
。事实上,在这种情况下我会给b b这样的作业提供建议,因为效果可能会稍微让人困惑。
-
Ben。
Presuming that the "<<<" and ">>>" are just there to mark the bit you
are asking about then, yes, it is valid. Both a and b are assigned
the value of c.
It is parsed as ''a = (b = c);''. The result of the right-hand b = c is
the value that b will have after the assignment and it is that
value that gets assigned to a (after any conversions). This matters
most when the types of a, b and c differ. In fact, in such a case I
would advise against an assignment like this since the effect can be
mildly confusing.
--
Ben.
这篇关于有效的C语法。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!