17. Initially, there were some gold coins and empty boxes to hold the coins. If each box is filled with 9 coins, there will be two empty boxes left; if each box is filled with 6 coins, there will be 3 coins left. Therefore, there are ( ) gold coins.
(A) 9
(B) 27
(C) 45
(D) 63
(E) 81
17. C.

Let there be $x$ boxes in total. According to the problem,
$$
9 x-18=6 x+3 \Rightarrow x=7 \text {. }
$$

Therefore, the number of gold coins is $9 \times 7-18=45$.