Compiled and written by Matti "ccr" Hamalainen of TNSP 2000-2001
Contact ccr/TNSP at:
- e-mail: ccr@tnsp.org
- www : http://www.tnsp.org/
Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.
There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.
1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]
struct foo {
struct bar {
int x;| #include <stdio.h> | |
| /* | |
| * Calculates what Ada Lovelace labeled "B7", which today we would call the 8th | |
| * Bernoulli number. | |
| */ | |
| int main(int argc, char* argv[]) | |
| { | |
| // ------------------------------------------------------------------------ | |
| // Data |
| using System; | |
| using System.Collections.Generic; | |
| using System.Web; | |
| using System.Web.Mvc; | |
| using System.Web.Optimization; | |
| using System.Web.Routing; | |
| using Microsoft.Extensions.DependencyInjection; | |
| using WebApplication16; | |
| using WebApplication16.Controllers; |
| =========================== | |
| SID FILE FORMAT DESCRIPTION | |
| =========================== | |
| AUTHORS: | |
| Michael Schwendt (PSID v1 and v2) | |
| Simon White (PSID v2NG, RSID) | |
| Dag Lem (PSID v2NG) | |
| Wilfred Bos (PSID v3, RSID v3, PSID v4, RSID v4) |
| using System; | |
| using System.Net.Http; | |
| using System.Web.Http.Controllers; | |
| using System.Web.Http.Dispatcher; | |
| using Microsoft.Extensions.DependencyInjection; | |
| namespace Web | |
| { | |
| public class ServiceProviderControllerActivator : IHttpControllerActivator | |
| { |
| // ... | |
| using Microsoft.Owin.Hosting; | |
| // ... | |
| public class ServiceHost | |
| { | |
| private IDisposable server = null; | |
| const string baseAddress = "https://*:443"; | |
| public void Start() |
| n=>{a=[].slice.call(n,0,9);a.push(a.reduce((s,d,i)=>{return s+d*(((i+1&1)*8)-1)},0)%10,a.reduce((s,d)=>{return s+1*d},0)%10);return n==a.join('')} |
korn.c is the "Best One Liner" winner of the 1987 International Obfuscated C Code Contest, by David Korn (yes, the author of the Korn Shell).
korn.hint, as the name implies, offers some hints.
A commenter on Stack Overflow asked for some clarification. I didn't want to post spoilers on the site, so I'm posting them here instead. If you haven't already (and if you're familiar with the rules of C) I encourage you to study the program for a while first.
=====
Here's the code: