?:作为左值 [英] ?: as an lvalue

查看:54
本文介绍了?:作为左值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有以下代码,我预计会出错,但是

i不会出错,


int main()

{

int aa = 0,b = 0;

1> ; 0?aa:b = 10;

printf(" value%d%d \ n",aa,b);

return(0); < br $>
}


和输出值0 0


提前致谢! ! !

Hi Everyone,

I have the following piece of code, and i expected an error, however
i don''t get an error,

int main()
{
int aa=0,b=0;
1>0?aa:b = 10;
printf("value %d %d\n",aa,b);
return(0);
}

and output is value 0 0

Thanks in advance ! ! !

推荐答案

文章< f8 *********************** *********** @ h11g2000prf。 googlegroups.com>,

Rahul< sa ***** @ yahoo.co.inwrote:
In article <f8**********************************@h11g2000prf. googlegroups.com>,
Rahul <sa*****@yahoo.co.inwrote:

>大家好,


我有以下代码,我预计会出错,但是我没有收到错误,

int main ()
{a / n = 0,b = 0;
1> 0?aa:b = 10;

printf(" value%d% d \ n",aa,b);

返回(0);
}
和输出值为0 0
提前致谢! ! !
>Hi Everyone,

I have the following piece of code, and i expected an error, however
i don''t get an error,

int main()
{
int aa=0,b=0;
1>0?aa:b = 10;
printf("value %d %d\n",aa,b);
return(0);
}

and output is value 0 0

Thanks in advance ! ! !



int main(void)更好

未能包括stdio.h

不必要地将返回值括起来

未能正确缩进退货声明

无意义的变量名称

未能大写i在文本中(例如,我没有收到错误)

过度使用感叹号

字词每个人的大写不正确

使用俗气的表情提前谢谢

int main(void) is better
failure to include stdio.h
unnecessarily parenthesizing the return value
failure to indent the return statement properly
meaningless variable names
failure to capitalize "i" in text (e.g., "i don''t get an error")
excessive use of exclamation points
improper capitalization of word "everyone"
use of tacky expression "Thanks in advance"


Rahul说:
Rahul said:

大家好,


我有以下代码,我预计会出错,但是

i不会出错,


int main()

{

int aa = 0,b = 0;

1> 0?aa:b = 10;
Hi Everyone,

I have the following piece of code, and i expected an error, however
i don''t get an error,

int main()
{
int aa=0,b=0;
1>0?aa:b = 10;



这是一个语法错误(因此需要实现

来诊断它)。条件运算符的语法是:


条件表达式:

logical-OR-expression

logical-OR-expression ?表达式:条件表达式


你的代码违反了。

This is a syntax error (which therefore requires the implementation to
diagnose it as such). The syntax of the conditional operator is:

conditional-expression:
logical-OR-expression
logical-OR-expression ? expression : conditional-expression

which your code violates.


printf(" value%d%d \ n" ;,aa,b);

返回(0);

}


和输出值0 0


提前致谢! ! !
printf("value %d %d\n",aa,b);
return(0);
}

and output is value 0 0

Thanks in advance ! ! !



调高警告级别。您使用的是哪种实现方式?


-

Richard Heathfield< http://www.cpax.org.uk>

电子邮件:-http:// www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - 1999年7月29日dmr

Turn up your warning level. Which implementation are you using?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


3月30日下午5:19,Richard Heathfield< r ... @ see.sig.invalidwrote:
On Mar 30, 5:19 pm, Richard Heathfield <r...@see.sig.invalidwrote:

Rahul说:
Rahul said:

大家好,
Hi Everyone,


我有以下代码,我预计会出错,但是

i没有收到错误,
I have the following piece of code, and i expected an error, however
i don''t get an error,


int main()

{

int aa = 0,b = 0;

1> 0?aa:b = 10 ;
int main()
{
int aa=0,b=0;
1>0?aa:b = 10;



这是一个语法错误(因此需要执行

来诊断它)。条件运算符的语法是:


条件表达式:

logical-OR-expression

logical-OR-expression ?表达式:条件表达式


你的代码违反了。


This is a syntax error (which therefore requires the implementation to
diagnose it as such). The syntax of the conditional operator is:

conditional-expression:
logical-OR-expression
logical-OR-expression ? expression : conditional-expression

which your code violates.


printf(" value%d%d \ n" ;,aa,b);

返回(0);

}
printf("value %d %d\n",aa,b);
return(0);
}


和输出值为0 0
and output is value 0 0


提前致谢! ! !
Thanks in advance ! ! !



调高警告级别。您使用的是哪种实现方式?


-

Richard Heathfield< http://www.cpax.org.uk>

电子邮件:-http:// www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日


Turn up your warning level. Which implementation are you using?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999



我试过MS VC ++ 8.0 ......
http://www.dinkumware.com/exam/default.aspx


这篇关于?:作为左值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆