p =(char *)malloc((sizeof(float))[" \000\006\010\013\015\100"]) [英] p=(char *)malloc((sizeof(float))["\000\006\010\013\015\100"])

查看:85
本文介绍了p =(char *)malloc((sizeof(float))[" \000\006\010\013\015\100"])的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是什么?

what''s this?

推荐答案

fuzhen说:
fuzhen said:

what这是?
what''s this?



检查主题行,我想你指的是:


p =(char *)malloc((sizeof) (浮动))[&\\\\\\\\\\\\\]


答案是,它是一个写错了对malloc的调用。但是,给了

合适的家具(包裹它的功能,< stdlib.h>等等 - 和一个

分号在那里不会出错),它是完全合法的,提供

sizeof(float)在目标系统上不超过6。在它b / b
的系统上,行为是未定义的。


让我们从假设sizeof(float)为3开始 - 这是完美的合法的

sizeof(浮动)的价值,并且具有不太可能的优点,至少说



因此,根据这个假设,代码简化为:


p =(char *)malloc((3)[" \000\006 \010 \ 013 \\ \\ 015 \ 100"])


和(3)只有3,所以这给了我们:


p =(char *) malloc(3 [&\\\\\\\\\\\])


现在,a [i]和*(a + i)保证是等价的,所以让我们做一些

代替:


p =(char *)malloc(*(3 +" \ 000\006 \010 \013 \ 015 \ 100"))


好​​的,x + y与y + x相同,所以:


p =(char *)malloc(*(" \000\006\010\013\015\100" +3))


和*(a + i)与[i]相同,所以:


p =(char *)malloc(" ; \ 000\006\010\013\015\100" [3])


现在," \000\006\010 \\ \\013\015\100"是一个值为{0,6,8,11,13,64,

0}的数组,所以\000\006 \010 \ 013 \ 015 \ 100 ; [3]是该数组的元素3:元素0

是0,元素1是6,元素2是8,元素3是11.所以我们可以替换

再次回来:


p =(char *)malloc(11)


最后我们可以失去虚假而毫无意义的演员阵容,这给了:


p = malloc(11)


这对你来说足够简单吗? (如果sizeof(float)在你的系统上没有碰到3,请记得用数组替换11不同的

值。)


-

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

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

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

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

Checking the subject line, I guess you are referring to this:

p=(char *)malloc((sizeof(float))["\000\006\010\013\015\100"])

to which the answer is that it''s a badly written call to malloc. But, given
suitable furniture (a function wrapped around it, <stdlib.h>, etc - and a
semicolon wouldn''t go amiss at the end there), it''s perfectly legal, provided
sizeof(float) doesn''t exceed 6 on the target system. On systems where it
does, the behaviour is undefined.

Let''s start off by assuming sizeof(float) is 3 - which is a perfectly legal
value for sizeof(float), and has the merit of being a little unlikely, to say
the least.

Thus, given that assumption, the code reduces to:

p=(char *)malloc((3)["\000\006\010\013\015\100"])

and (3) is just 3, so that gives us:

p=(char *)malloc(3["\000\006\010\013\015\100"])

Now, a[i] and *(a + i) are guaranteed to be equivalent, so let''s do some
substituting:

p=(char *)malloc(*(3+"\000\006\010\013\015\100"))

Okay, x+y is the same as y+x, so:

p=(char *)malloc(*("\000\006\010\013\015\100"+3))

and *(a + i) is the same as a[i], so:

p=(char *)malloc("\000\006\010\013\015\100"[3])

Now, "\000\006\010\013\015\100" is an array with values { 0, 6, 8, 11, 13, 64,
0 }, so "\000\006\010\013\015\100"[3] is element 3 of that array: element 0
is 0, element 1 is 6, element 2 is 8, element 3 is 11. So we can substitute
that back in again:

p=(char *)malloc(11)

and finally we can lose the spurious and utterly pointless cast, which gives:

p = malloc(11)

Is that sufficiently simple for you? (Remember to replace 11 with a different
value from the array if sizeof(float) doesn''t happen to be 3 on your system.)

--
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




这对你来说足够简单了吗? (如果sizeof(float)没有碰巧是你的
$ b $,请记住用数组替换11和

不同的

值b系统。)
Is that sufficiently simple for you? (Remember to replace 11 with a
different
value from the array if sizeof(float) doesn''t happen to be 3 on your
system.)



这样的东西是否合法使用?

Does something like this have a legitimate use at all?


MisterE说:
MisterE said:

>
>

>这对您来说足够简单吗? (如果sizeof(float)在你的
系统上没有碰到3,请记住从数组中替换为具有不同
值的11。)
>Is that sufficiently simple for you? (Remember to replace 11 with a
different
value from the array if sizeof(float) doesn''t happen to be 3 on your
system.)



这样的东西有合法用途吗?


Does something like this have a legitimate use at all?



否 - 让新手感到困惑的是它的极限。真的。


-

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

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

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

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

No - confusing the newbies is about its limit, really.

--
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


这篇关于p =(char *)malloc((sizeof(float))[&quot; \000\006\010\013\015\100&quot;])的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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