〜ことか
how (very)! (exclamation)
どんなに / 何度 / どれほど + Plain form + ことか
Sign up free to review this point on a spaced schedule.
ことか turns a sentence into a heartfelt exclamation: 合格の知らせを聞いて、どんなにうれしかったことか, "how happy I was to hear I'd passed!"
It usually pairs with a question word of degree: どんなに, どれほど, どれだけ ("how much") or 何度 ("how many times"). The sentence looks like a question, but it's really an emphatic statement.
It's common for strong feelings (joy, loneliness, longing) and for exasperation: 何度注意したことか, "how many times have I told you!"
It's literary and a bit dramatic. Don't confuse it with ものか, "as if I would!", which is a refusal.
Examples
合格の知らせを聞いて、どんなにうれしかったことか。
How happy I was to hear I'd passed!
何度注意したことか。
How many times have I told you!
一人で暮らすのがどれほど寂しいことか。
You have no idea how lonely it is to live alone.
この日をどんなに待っていたことか。
How long I've waited for this day!
母の料理がどれだけ懐かしかったことか。
How I missed my mother's cooking!