Q:

How is this value calculated?

This is from a past paper at university.
There's a struct initialised:
struct double {int value; struct * double pred; struct * double succ;};

Then in the main function:
main(...)
{
    struct double * d1, * d2, * d3;
    d1 = newDouble(33);
    d2 = newDouble(55);
    d3 = newDouble(77);
    d1 -> succ = d2;
    d2 -> pred = d1;
    d2 -> succ = d3;
    d3 -> pred = d2;

    printf("%d/n", d1->succ->succ->pred->value); // ??
}

What I don't understand is what the -> does in printf. I can't work out what the value would actually be.

A:

-> is dereferencing the pointers to access fields: d1->succ is shorthand for (*d1).succ.
With this convoluted construction: d1->succ->succ->pred->value, you'll end up with the value of d2, presumably 55:

d1->succ is d2.
So d1->succ->succ is equivalent to d2->succ, which is d3.
So d1->succ->succ->pred is equivalent to d3->pred, which is d2.
So d1->succ->succ->pred->value is equivalent to d2->value.

