只想要详细信息 [英] just want detail information
问题描述
main()
{
int a = 1;
int c,d;
c = ++ a + ++ a + ++ a;
printf(" \ n%d",a);
printf(" \ n %% d",c);
getch();
}
上面给出的代码给出的值是一个"和c分别为4和12分。
谁能告诉我为什么会这样......
ashu写道:
>
main()
{
int a = 1;
int c,d;
c = ++ a + ++ a + ++ a;
printf(" \ n%d",a);
printf(" \ n%d",c);
getch();
}
上面给出的代码给出了a的值。和c分别为4和12分。
任何人都可以告诉我为什么会这样......
http://docs.mandragor.org/files/Prog...-faq/ q3.2.html
-
pete
ashu< as************@gmail.comwrites:
c = ++ a + ++ a + ++ a;
上面给出的代码给出了a的值。和c分别为4和12分。
任何人都可以告诉我为什么会这样......
因为你不走运。
如果你很幸运,编译器会拒绝编译这个
来源。
如果你是使用我尚未编写的编译器,它会将
删除源文件并显示
标准的相关部分(明确将其描述为未定义行为)
高对比度刻字,直到你通过图灵测试它管理
以确保你理解这一点。
mlp
4月22日凌晨2:35,Mark L Pappin< m ... @ acm.orgwrote:
ashu< ashishmoury ... @ gmail.comwrites:
c = ++ a + ++ a + ++ a;
上面给出的代码给出了a的值。和c分别为4和12。
任何人都可以告诉我为什么会这样...
因为你是不幸的。
如果你很幸运,编译器会拒绝编译这个
来源。
如果你使用的编译器还没有编写,它会将
删除源文件并显示
标准的相关部分(明确地将其描述为未定义的行为) )在
高对比度刻字中,直到你通过图灵测试它管理
以确保你理解这一点。
mlp
实际上我想要查看一个特定的行
" c = ++ a + ++ a + ++ a;
编译器如何计算它和y?在不同的
编译器上它会有所不同。
i认为它应该被视为
c = 2 + 3 + 4。
main()
{
int a = 1;
int c,d;
c = ++a + ++a + ++a;
printf("\n%d",a);
printf("\n%d ", c);
getch();
}
The above given code gives the value of "a" and "c" as 4 and 12 resp.
Can anyone tell me why it is so...
ashu wrote:>
main()
{
int a = 1;
int c,d;
c = ++a + ++a + ++a;
printf("\n%d",a);
printf("\n%d ", c);
getch();
}
The above given code gives the value of "a" and "c" as 4 and 12 resp.
Can anyone tell me why it is so...http://docs.mandragor.org/files/Prog...-faq/q3.2.html
--
pete
ashu <as************@gmail.comwrites:
c = ++a + ++a + ++a;
The above given code gives the value of "a" and "c" as 4 and 12 resp.
Can anyone tell me why it is so...Because you were unlucky.
If you were lucky, the compiler would have refused to compile this
source.
If you were using the compiler I have not yet written, it would have
deleted the source file and displayed the relevant part of the
standard (that explicitly describes this as Undefined Behaviour) in
high-contrast lettering until you passed a Turing test it administered
to ensure you understood the point.
mlp
On Apr 22, 2:35 am, Mark L Pappin <m...@acm.orgwrote:ashu <ashishmoury...@gmail.comwrites:c = ++a + ++a + ++a;
The above given code gives the value of "a" and "c" as 4 and 12 resp.
Can anyone tell me why it is so...
Because you were unlucky.
If you were lucky, the compiler would have refused to compile this
source.
If you were using the compiler I have not yet written, it would have
deleted the source file and displayed the relevant part of the
standard (that explicitly describes this as Undefined Behaviour) in
high-contrast lettering until you passed a Turing test it administered
to ensure you understood the point.
mlpactually i want to abt one specific line
" c=++a + ++a + ++a;
how compiler calculate it and y? will it be different on different
compilers.
i think it should taken as
c= 2+3+4.
这篇关于只想要详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!