URL in C Puzzle

Programmers freak out as a URL compiles in C—comments go wild

TLDR: A URL inside C code compiles because “https:” is treated as a label and “//” turns the rest into a comment. Commenters split between clever hacks, strict style rules, and C++ praise, with a viral story of a pasted YouTube link proving why code reviews—and comment styles—matter.

A tiny C program just slipped a web link right into its code—think “https://susam.net/” sitting on a line—and still printed hello, world like nothing happened. The community exploded with reactions, from smug know‑it‑alls to stunned onlookers. The twist: in C99 (the 1999 version of the C standard), “https:” is read as a label and “//” starts a comment, so the rest of the URL gets ignored. Mystery solved, drama ignited. Read the puzzle on susam.net.

One camp, led by the “I’ve seen things” crowd, bragged about using this trick to stash shell commands in their code, flexing editor F‑key magic. Another camp clutched pearls: a stern voice declared, “only use /* */,” sparking a mini‑war over comment style. The C++ fans swooped in, declaring “// comments” one of the few things C++ got right, turning it into an old‑school vs. modern showdown. The funniest moment? A tale of a teammate accidentally pasting a YouTube link into Java—instant proof of “working hard” on videos, and the office knew exactly which one. Meanwhile, a cool‑headed commenter explained the label‑and‑comment combo, like a magician revealing the trick.

It’s a perfect storm: a simple code snippet, a quirky language rule, and a comments section roasting, teaching, and meme‑ing all at once.

Key Points

  • A URL-like line in a C program compiles because “https:” is parsed as a valid label.
  • In C99, “//” begins a single-line comment, so the remainder of the URL text is ignored.
  • C99 section 6.4.9 specifies that “//” introduces a comment up to the next newline.
  • The program compiles with a C99 compiler and outputs “hello, world.”
  • Labels in C can exist without being referenced, contributing to the code’s validity.

Hottest takes

"I do this to embed shell commands..." — gblargg
"This is why you should only use /* */" — writebetterc
"C++ got it right: // comments are one of the best" — raverbashing
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.