表达式“sizeof(int)* p”是什么?意思?

编程入门 行业动态 更新时间:2024-10-23 22:27:47
本文介绍了表达式“sizeof(int)* p”是什么?意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否意味着(sizeof(int))*(p)或sizeof((int)(* p)) ? 根据我的分析,运算符sizeof,(type)和*具有相同的 优先级,并且它们从右到左组合。那么这个表达式应该等于sizeof((int)(* p)),但是编译器并不这么认为。为什么? 任何人都可以帮助我吗?谢谢。 祝你好运。 Roy

Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this expression should equal to "sizeof( (int)(*p) )", but the compiler does NOT think so. Why? Can anyone help me? Thanks. Best regards. Roy

推荐答案

" Roy Yao" < FL *** @ 263>在消息新闻中写道:< bk *********** @ mail99> ... "Roy Yao" <fl***@263> wrote in message news:<bk***********@mail99>... 是否意味着(sizeof(int))*( p)"或sizeof((int)(* p)) ? 根据我的分析,运算符sizeof,(type)和*具有相同的优先级,并且它们从右到左组合。那么这个表达式应该等于sizeof((int)(* p)),但是编译器并不这么认为。为什么? 任何人都可以帮助我吗?谢谢。 致以最诚挚的问候。 Roy Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this expression should equal to "sizeof( (int)(*p) )", but the compiler does NOT think so. Why? Can anyone help me? Thanks. Best regards. Roy

嘿, 两者都是;(sizeof(int))*(p)或sizeof((int)(* p))是不一样的。 "(sizeof(int))*(p)"意味着你将sizeof(int),即2 (字节)乘以p的值。而sizeof((int)(* p))意思是, 首先你得到了adderess p的值(因为* p给出了另一个变量的价值),然后你转换了返回的 值为整数格式,最后你检测到结果的大小为 。如果您对我的ID有任何疑问,请联系 ke ********* **@yahoo.co.in 。 很酷, Y. Keerthi Sagar& Ashok。

Hey, Both "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" are not same. "(sizeof(int))* (p)" means you are multiplying sizeof(int), i.e. 2 (bytes), with the value of "p". Whereas "sizeof( (int)(*p) )" means, First you are getting the value of at the adderess p (because *p gives the value of another variable), then you are converting the returned value into interger format and finally you are detecting the size of that result. If you have any doubts contact at my ID ke***********@yahoo.co.in. Be Cool, Y. Keerthi Sagar & Ashok.

Hello Keerthi, 感谢您的热情。 我的发送给你的邮件被你的邮件服务器拒绝了,所以我在这里回复你。 在这个表达式中,让我困惑的是编译器(或ANSI C)如何确定运算符sizeof,(type)和*的组合。 在我的opion中,它应该等于表达式sizeof((int)(* p))。 的原因是运算符sizeof,(type)和*具有相同的 优先级,并且它们从右到左组合。但是编译器更喜欢 "(sizeof(int))*(p)"。 现在你可以从优先级给我一个有信心的解释和运营商的组合订单? 再次感谢。 祝你好运, Roy Yao Hello Keert Thanks for your enthusiasm. My email to you was rejected by your mail server, so I reply you here. In this expression, what confused me is how the compilers (or ANSI C) determine the combination of operator sizeof, (type) and *. In my opion it should equal to expression "sizeof( (int)(*p) )". The reason is that operator sizeof, (type) and * have the same precedence, and they combine from right to left. But the compilers prefer "(sizeof(int))* (p)". Now can you give me a convictive explain from the precedence and combination order of operator ? Thanks again. Best regards, Roy Yao

On Tue,2003年9月16日08:44:02 +0800,Roy Yao写道: On Tue, 16 Sep 2003 08:44:02 +0800, Roy Yao wrote: 你好Keerthi, 感谢您的热情。 我的电子邮件被您的邮件服务器拒绝了,所以我在这里回复。 表达式,令我困惑的是编译器(或ANSI C)如何确定运算符sizeof,(type)和*的组合。 在我的opion中它应该等于表达式sizeof ((int)(* p))。 原因是运算符sizeof,(type)和*具有相同的优先级,并且它们从右到左组合。但是编译器更喜欢(sizeof(int))*(p)。 现在你可以从优先级和组合顺序给我一个有说服力的解释。运营商? Hello Keert Thanks for your enthusiasm. My email to you was rejected by your mail server, so I reply you here. In this expression, what confused me is how the compilers (or ANSI C) determine the combination of operator sizeof, (type) and *. In my opion it should equal to expression "sizeof( (int)(*p) )". The reason is that operator sizeof, (type) and * have the same precedence, and they combine from right to left. But the compilers prefer "(sizeof(int))* (p)". Now can you give me a convictive explain from the precedence and combination order of operator ?

我在其他帖子中告诉你,那不是(类型)运营商! (类型)是 /操作数/ sizeof。 Josh

I told you in my other post, that''s NOT the (type) operator! (type) is the /operand/ of sizeof. Josh

更多推荐

表达式“sizeof(int)* p”是什么?意思?

本文发布于:2023-08-01 04:23:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1265185.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   sizeof   int

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!