D Language Memory & Pointers Pointers


D is a system programming language and thus allows you to manually manage and mess up your memory. Nevertheless, D uses a garbage collector per default to free unused memory.

D provides pointer types T* like in C:

void main()
    int a;
    int* b = &a; // b contains address of a
    auto c = &a; // c is int* and contains address of a

    import std.stdio : writeln;
    writeln("a ", a);
    writeln("b ", b);
    writeln("c ", c);