avatar
r*c
1
why *d is evaluate first then ++? In the precedence table it shows ++ (
postfix) is higher than dereference.
avatar
z*g
2
It's easy to confuse operator precedence with order of evaluation. Operator
precedence only decides how operators match with operands, not the order
they are evaluated.
You are correct that the precedence of postfix is higher than dereference.
But that only tells you *d++ should be *(d++) but not (*d)++. This does not
conflict with the fact that postfix is evaluated after the statement.
Hope that helps.
avatar
r*c
3
So this means it's equivalent to
*d = *s;
d++;
s++;
right?
avatar
z*g
4
Yes. That is correct.
avatar
r*c
5
Thanks! Yesterday I had a phone interview with Google.
The interviewer thought it's wrong to use *d++ = *s++ to do copy as ++ will
happen before *. Shall I find a way to tell him? (via recruiter). Will
that have any influence on his decision?
avatar
p*y
6
这代码风格不好啊。表达式有副作用,而且是容易弄错的副作用。多写一两行少很多歧
义。

will

【在 r**c 的大作中提到】
: Thanks! Yesterday I had a phone interview with Google.
: The interviewer thought it's wrong to use *d++ = *s++ to do copy as ++ will
: happen before *. Shall I find a way to tell him? (via recruiter). Will
: that have any influence on his decision?

avatar
N*D
7
这真有人考啊?回字的四种写法?
avatar
s*x
8
面试千万不要写这种code.
To me, this is only used in the famous string Copy:
While ( *d++=*s++);
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。