I need to prove that $K\subseteq \mathbb{R}^n$ is a compact space iff every continuous function in $K$ is bounded.

One direction is obvious because of Weierstrass theorem. How can i prove the other direction?
I tried to assume the opposite but it didn't work for me.

Thanks a lot.