Suppose that $X$ is a metric space. Is the family of all real-valued uniformly continuous functions on $X$ dense in the space of all continuous functions with respect to the topology of uniform convergence on compact sets?



Are uniformly continuous functions dense in all continuous functions?
Yes, and even more is true. The argument is as follows: let $f\colon X \to \mathbb R$ be a continuous function and let $K\subset X$ be a compact set. Then $f|\_K$ is uniformly continuous; let $\omega$ be its nondecreasing subadditive modulus of continuity. By [McShane-Whitney's extension formula](https://en.wikipedia.org/wiki/Whitney_extension_theorem) $f|\_K$ admits a uniformly continuous extension to $X$ with the same modulus - more concretely, $$F(x)=\inf\{f(k)+\omega(d(k,x))\colon k\in K\}$$ is this extension which is uniformly continuous on the whole $X$.


