To the men in hats question, C calls out.
Why? Because D can see both C and B, but doesn't say anything. That alerts C, because if B and C both had white hats, D could have confidently answered, saying he had a black hat.
This let's C know that his hat color must be different from B's, ands thus he knows his hat is white.