The URL That Compiles in C
Here is a silly little C puzzle: #include <stdio.h> int main(void) { https://susam.net/ printf("hello, world\n"); return 0; } This code compiles and runs successfully. $ c99 hello.c && ./a.out hello, world However, the C99 standard draft does not mention anywhere that a URL is a valid syntactic element in C. How does this code work then?
A screenshot presents a C program containing a bare URL, followed by a successful compilation and “hello, world” output. The joke is that in C, the URL is parsed as a label named “https:” followed by a comment beginning with “//”, so the apparently invalid line is ignored. EN: A screenshot presents a C program containing a bare URL, followed by a successful compilation and “hello, world” output. The joke is that in C, the URL is parsed as a label named “https:” followed by a comment beginning with “//”, so the apparently invalid line is ignored.
C source code / исходный код на Ccode editor text / текст редактора кодаURL / URL-адресterminal command / команда терминалаterminal output / вывод терминалаgray code block / серый блок кодаgreen syntax highlighting / зелёная подсветка синтаксисаblue hyperlink / синяя гиперссылкаbraces / фигурные скобкиtext document / текстовый документ
- @ithueti / 17347 2025-12-02
- Type
- image
- Size
- 800×499 · 43.0 KiB
- Mood
- clever, absurd
- Language
- en
- Added