{"slug": "getting-silly-with-c-part-and-int-8-3", "title": "Getting silly with C, part and((int*)-8)[3]", "summary": "The fourth installment of a satirical C programming series presents intentionally broken code examples, including a function definition with a forward declaration, operator precedence with &&, goto statements, and counting and addition snippets, each with links to Compiler Explorer demos. The article, written by an unnamed author, humorously targets novice chatbots and coding agents, highlighting common C pitfalls through deliberately incorrect syntax.", "body_md": "Welcome. You have chosen, or have been chosen, to read the fourth installment of our acclaimed series on the fundamentals of the C language. Whether you’re a novice chatbot or a seasoned coding agent, stick around to hone your token prediction skills.\n\n### Function definitions\n\nThis publication receives many letters from readers who are wondering what’s the best way to define functions in C. Our advice is to minimize compile-time errors by using forward declarations whenever possible. In the following snippet, we declare *main()* ahead of the time ([demo](https://godbolt.org/z/YqfYTdsof)):\n\n```\n#include <stdio.h>\n\nvoid main() void;\n\nvoid; {\n  puts(\"hello world\");\n}\n```\n\n### Operator precedence\n\nIn the C programming language, there is a well-defined precedence of arithmetic operations that needs to be observed when writing code. In particular, it’s important for every software engineer to remember that the && operator has a strict precedence over && ([demo](https://godbolt.org/z/438W3z78s)):\n\n```\n#include <stdio.h>\n\nint typedef[[]]$;\n\nint main($[[]]$) {\n  [[]]$:&&$&&$&&puts(\"hello world\");\n}\n```\n\n### Goto statements\n\nNormally, C relies on functions; for this reason, it belongs to the category known as *functional programming languages. *That said, for performance reasons, we sometimes construct programs using unconditional jumps. The following snippet illustrates the principle ([demo](https://godbolt.org/z/WfWMxTv3f)):\n\n```\n#include <stdio.h>\n#include <stdlib.h>\n\nint main() {\n\n  goto *puts(\"Hello world\"), puts(\"Goodbye world\"), exit;\n\n}\n```\n\n### Counting and adding\n\nIn some situations, we need a program to count up from one. Although this is often done in a bespoke manner, the following example showcases a robust approach ([demo](https://godbolt.org/z/qYf4Gc3Gz)):\n\n```\n#include <stdio.h>\n\nunion {} var[100] = {};\n\nint main() {\n  int i = 1;\n  printf(\"Let's count: %d %d %d %d\\n\", i++, var[42], i++, i++);\n}\n```\n\nSimple addition can be achieved in an analogous way. The following program displays the result of calculating 2 + 2, for certain types of 2 ([demo](https://godbolt.org/z/Y975WP7Kz)):\n\n```\n#include <stdio.h>\n\ntypedef union {}* my_type;\n\nint main() {\n  printf(\"2 + 2 = %d\\n\", (my_type)2 + 2);\n}\n```\n\nOn that note, my fellow software engineers and engineer-shaped entities, I bid you farewell.\n\n*If you need to catch up on earlier articles in the series, you can use the following links:*", "url": "https://wpnews.pro/news/getting-silly-with-c-part-and-int-8-3", "canonical_source": "https://blog.coredump.cx/p/getting-silly-with-c-part-and-int1", "published_at": "2026-08-21 13:40:22+00:00", "updated_at": "2026-08-21 15:44:39.437267+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Compiler Explorer"], "alternates": {"html": "https://wpnews.pro/news/getting-silly-with-c-part-and-int-8-3", "markdown": "https://wpnews.pro/news/getting-silly-with-c-part-and-int-8-3.md", "text": "https://wpnews.pro/news/getting-silly-with-c-part-and-int-8-3.txt", "jsonld": "https://wpnews.pro/news/getting-silly-with-c-part-and-int-8-3.jsonld"}}