The whole question: Given $f: X \rightarrow \mathbb{R}$, suppose that for every $\epsilon>0$ we can obtain some continuous function $g: X \rightarrow \mathbb{R}$ such that $|f(x)-g(x)|<\epsilon$ for any/arbitrary/whatever $x\in X$. Prove that $f$ is also continuous.
What i've tried so far: given $a\in \mathbb{R}$, manipulate
$|f(x)-f(a)| = |f(x)-f(a)+g(a)-g(a)+g(x)-g(x)| \leq$
$|g(a)-f(a)|+|g(x)-g(a)|+|f(x)-g(x)|$,
and, taking some care with $\epsilon$, this would imply $|f(x)-f(a)| $ less than $\epsilon$. But i can't ensure that we are talking about the same $g$, since for every different $x$ it is possible to approximate $f$ with some $g$.
Any hints?