Usually one employs Urysohn's Lemma to proof the above identity.
See for example here in the first answer: Show that the closure of $C_c(X)$ is $C_0(X)$.
I find that proof rather complicated compared to the following one.
Additionally in the proof in the link we need $X$ to be Hausdorff.
Now I've seen the following proof which does not use any property of $X$ and is quite simple aswell. It doesn't even have to be a Hausdorff-space. This is weird to me and I think there must be a mistake in it but I can't find it.
$f\in C_0(x)$. Define $f_\epsilon(x) = \begin{cases}0\quad &\text{if }|f(x)|< \epsilon\\ f(x)-\epsilon\frac{f(x)}{|f(x)|}\quad &\text{if }|f(x)|\geq \epsilon.\end{cases}$
$f_\epsilon \to f$ uniformly follows immidiately by distinguishing cases if $|f(x)|$ is bigger or smaller than $\epsilon$.
Additionally $f_\epsilon$ has compact support because $\{|f|\geq \epsilon\}$ is compact.
By the https://en.wikipedia.org/wiki/Pasting_lemma $f_\epsilon$ is continuous.
If this really would be correct, I wonder why this simple and more general proof isn't the one one usually sees.
Edit: As requested, more details:
1) $f_\epsilon\to f$ uniformly: Let $x\in X$. If $|f(x)|<\epsilon$, then $|f(x)-f_\epsilon(x)| = |f(x)|<\epsilon$. If $|f(x)|\geq \epsilon$ then $|f(x)-f_\epsilon(x)| = \epsilon\left|\frac{f(x)}{|f(x)|}\right| = \epsilon$, hence $\|f-f_\epsilon\|_\infty\leq \epsilon$.
2) $\{|f|\geq \epsilon\}$ is compact: Since $f\in C_0(X)$, there is compact $A\subset X$ with $|f(x)|<\epsilon$ if $x\notin A$, therefore $\{|f|\geq \epsilon\}\subseteq A$ and $\{|f|\geq \epsilon\}$ is a closed subset of a compact set and therefore compact.