私はこのペーストに出くわしました:
int main() {
return!!!~!!!!!~!!!1??!??!1?
"^_^" <:3
]: "^.-"
<: 0.0
<3 :> ;}
null を返すとされるかわいい顔文字のコレクション。C-fuが私のものよりも優れている人は、それがどのように機能するかを説明していますか?
<:
means [
, :>
means ]
(they're digraphs).
??!
means |
(it's a trigraph), so ??!??!
is logical ||
The last ?
on the first line is a conditional operator.
The remainder selects one character from one of the two emoticon strings. It will select from the first one, since regardless of how many !
and ~
there are in the mess at the start, anything || 1
is true.
So it actually selects "^_^"[3]
, which is the nul terminator at the end of the string, which is 0.
Basically the code reads return ((some mess) || 1) ? "^_^"[3] : "^.-"[1];
, since 0.0 < 3
is true.
[Edit: I just realised (and commented below), it is possible to write a conforming implementation on which ~(expression equal to 0)
has undefined behavior. So to know whether or not this code is strictly conforming, you have to check that neither of the ~
is applied to a zero. In fact !!!1
is 0
, so the code doesn't strictly conform. It'll work on any implementation you can name, though, since approximately everything uses 2's complement.]