6

C 語言的兩個笑話 (以及他的惡搞原理)

 2 years ago
source link: https://blog.gslin.org/archives/2022/03/20/10618/c-%e8%aa%9e%e8%a8%80%e7%9a%84%e5%85%a9%e5%80%8b%e7%ac%91%e8%a9%b1-%e4%bb%a5%e5%8f%8a%e4%bb%96%e7%9a%84%e6%83%a1%e6%90%9e%e5%8e%9f%e7%90%86/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

C 語言的兩個笑話 (以及他的惡搞原理)

Twitter 上看到兩則 C 語言的笑話:

第一個的 "-0.5"char[],補了 + 1 會往後一格,所以會變成移到 "0.5" 的部份。

所以如果改成 -0.6,你會發現輸出變成 0.6

第二個的 50 ** "2" 則是利用了 2 的 ascii code 是 0x32,換成十進制剛好是 50,然後中間的 ** 其實是一個乘號與一個 pointer 的用法,實際上剛好會是 50*50=2500 的運算。

如果你改成 "3" 的話會輸出 2550

作者在 Twitter 的後續有提到,這些都是特別挑過的數字所造成的「巧合」,你換掉這些數字的話通常會爛掉
(除非你也很精心挑過),不要誤解亂用 XDDD

Related

雞肋功能:AWS 推出 Managed Prefix Lists 管理 IP 列表

AWS 總算推出可以管理 IP 列表的功能 Managed Prefix Lists,就不需要自己在 security group 裡面針對一堆 IP 設重複的設定:「Amazon Virtual Private Cloud (VPC) customers can now use their own Prefix Lists to simplify the configuration of security groups and route tables」。 目前這個功能在大多數的區域都開放使用了: There is no additional charge to use the Prefix Lists. Support for Prefix Lists is…

July 1, 2020

In "AWS"

幫 Pixnet 做 Fulltext Search

這幾天總算是比較接近完成的階段了,在問過 far 之後來寫一篇講一下。 大約是在年初的時候 far 就想要將 Pixnet Blog 的部份弄 Fulltext Search,剛好那陣子我也在弄類似的東西,survey 一些對 CJK 支援比較好的 Fulltext Search Engine,當時看起來比較好用是 平林幹雄 維護的 HyperEstraier。(我也寫了 HyperEstraier 與 HyperEstraier 與 qdbm 的一些雜記 兩篇文章) 不過後來 HyperEstraier 將近三個月沒更新,加上 Pixnet 那陣子在忙公司整合的事情,所以這件事情在收了訂金後就一直擱著... (皇上都不急了,太監就不要在旁邊跳腳...) 除了 HyperEstraier 外,我還有訂另外幾個 Fulltext Search Engine 的 mailing list,其中 Gmane 用的 Xapian 也蠻值得關注的。我從 0.9.x 版的時候就在觀察,當時連 UTF8 support…

June 15, 2007

In "Blog"

Kubernetes 的失敗案例

有人把 Kubernetes (通常縮寫成「K8S」) 的失敗案例 (轉移失敗、爛掉、...) 整理到 GitHub 上:「Kubernetes Failure Stories」,裡面有文章也有演講影片,然後也有重複的公司在不同時間點說明。 先來講 K8S 好了,如果要粗略的解釋 K8S 是什麼東西,我會說就像是架一組 AWS 服務起來,但是是基於 container 而非 VM。 拿 AWS 的詞彙來說,他在上面疊了一層 Amazon VPC (會對應到 Kubernetes 的 overlay network 與 CNI),然後也提供 AMI (透過 Docker Image) 與 EC2 (因為是比喻,這邊就拿 AMI + EC2 來對比),還有基本的 ELB (各種 NodePort、HostPort 與 Ingress) 與 Service…

January 30, 2019

In "Cloud"

a611ee8db44c8d03a20edf0bf5a71d80?s=49&d=identicon&r=gAuthor Gea-Suan LinPosted on March 20, 2022Categories Computer, Joke, Murmuring, Programming, RecreationTags c, fun, javascript, joke, js

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)

Post navigation


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK