Skip to content

Instantly share code, notes, and snippets.

View tyler569's full-sized avatar

Tyler Philbrick tyler569

  • San Francisco, USA
View GitHub Profile
@tyler569
tyler569 / Quirks of C.md
Created September 10, 2018 19:27 — forked from fay59/Quirks of C.md
Quirks of C

Here's a list of mildly interesting things about the C language that I learned 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;
   } baz;
};
struct Foo<'a> {
a: String,
b: &'a str,
}
impl<'a> Foo<'a> {
fn new() -> Foo<'a> {
Foo { a: String::new(), b: "" }
}