For any point $a$ of a compact subset $S$ of a metric space $(X, p)$, prove that there exists a nearest point $ c $ to $ a $. Let $S$ be a compact subset of $X$. Define a metric space $(X, p).$ Prove that for any point $a\in X$, there exists a nearest point $c$ in $S$ to $a$. Moreover, $c$ in $S$ such that $p(c,a)\leq p(x,a)$ for all $x \in S$. 
My thought is to use  function $f: S \to\mathbb R$, where $f(x)= p(x,a).$

Since your $f$ is continuous and $S$ is compact so is $f(S)$ but in $\mathbb{R}$. Hence $f(S)$ contains its infimum.
