postfix运算符的操作数 - > [英] Operand of postfix operator ->
问题描述
考虑以下代码:
int main()
{
struct name
{
长a;
int b;
长c;
} s = {3,4,5}, * p;
p =& s;
printf("%d",*(int *)((char *)p +(unsigned int )&(((struct name *)0) -
Consider the following code:
int main()
{
struct name
{
long a;
int b;
long c;
}s={3,4,5},*p;
p=&s;
printf("%d",*(int *)((char *)p+(unsigned int)&(((struct name*)0)-
> b)));
>b)));
返回0;
}
是表达式(unsigned int)&( ((结构名称*)0) - > b)有效按
C99?
即
可以一个postfix运算符的操作数-be一个空指针?
请澄清。
预先感谢您的回复。
return 0;
}
Is the expression (unsigned int)&(((struct name*)0)->b) valid as per
C99?
That is,
Can an operand of postfix operator -be a null pointer?
Please clarify.
Thanks in advance for the reply.
推荐答案
在文章< 11 ********************** @ n35g2000prd。 googlegroups .com>,
Rajesh SR< SR ********** @ gmail.comwrote:
In article <11**********************@n35g2000prd.googlegroups .com>,
Rajesh S R <SR**********@gmail.comwrote:
> ;表达式(unsigned int)&(((struct name *)0) - > b)是否符合
C99?
>Is the expression (unsigned int)&(((struct name*)0)->b) valid as per
C99?
No.
No.
>即
后缀运算符的操作数可以 - 是一个空指针?
>That is,
Can an operand of postfix operator -be a null pointer?
- 不是后缀运算符。它有两个操作数,显示在
之间,所以它是一个中缀操作符。
- Richard
- -
考虑在一些字母表中需要多达32个字符
- X3.4,1963。
-is not a postfix operator. It has two operands and appears between
them, so it''s an infix operator.
-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Rajesh SR写道:
Rajesh S R wrote:
请考虑以下代码:
int main()
{
struct name
{
long a;
int b;
long c;
} s = {3,4,5},* p;
p =&安培; S;
Consider the following code:
int main()
{
struct name
{
long a;
int b;
long c;
}s={3,4,5},*p;
p=&s;
如果我们配对,我不会让它保持这样。哦不。
Were we pairing, I''d not let that stay like that. Oh no.
printf("%d",*(int *)((char *)p +(unsigned int)&(((struct name * )0) -
printf("%d",*(int *)((char *)p+(unsigned int)&(((struct name*)0)-
>> b)));
>>b)));
此时我会问你到底想要做什么。
我不会''是否合法是否符合标准;我会谅解它是不礼貌的。
At this point I''d ask you what on earth you were trying to do.
I wouldn''t much care whether it was legal-by-the-Standard; I''d
care that it was indecently obscure.
返回0;
}
表达式(unsigned int)&(((struct name *)0) - > b)是否有效
C99?
return 0;
}
Is the expression (unsigned int)&(((struct name*)0)->b) valid as per
C99?
我不这么认为。
I don''t think so.
即
后缀运算符的操作数可以是空指针吗?
That is,
Can an operand of postfix operator -be a null pointer?
是的,可以。结果未定义。所以不要这样做。
(您的澄清问与您的原件有不同的问题。)
-
最好在朋友之间进行挑选。
Hewlett-Packard Limited注册办公室:Cain Road,Bracknell,
注册号:690597英格兰Berks RG12 1HN
Yes, it can be. The result is undefined. So don''t do that.
(Your clarification asks a different question from your original.)
--
Nit-picking is best done among friends.
Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN
在文章< f0 ********** @ murdoch.hpl.hp.com>中,
Chris Dollin< ch ********** @ hp.comwrote:
In article <f0**********@murdoch.hpl.hp.com>,
Chris Dollin <ch**********@hp.comwrote:
> ; printf("%d",*(int *)((char *)p +(unsigned int)&(((struct name *)0) -
>printf("%d",*(int *)((char *)p+(unsigned int)&(((struct name*)0)-
>>> b)));
>>>b)));
>此时我会问你到底想要做什么。
>At this point I''d ask you what on earth you were trying to do.
据推测,他正在尝试实施sizeof(),因为显然印度每个人现在都在做b $ b。我认为他和所有人一样都在同一个课程上。其他人也提出类似的问题。
- Richard
- -
考虑在一些字母表中需要多达32个字符
- 1963年的X3.4。
Presumably he''s trying to implement sizeof(), as apparently everyone
in India is doing these days. I assume he''s on the same course as all
the others asking similar questions.
-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
这篇关于postfix运算符的操作数 - >的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!