A sequence of continuous functions converging to a discontinuous function Let $f:I\to \mathbb R$ be a function which is continuous in every points of the interval $I$ except of a finite number of discontinuities $c_1,...,c_n$. I would like to find a sequence of continuous functions $f_n:I\to \mathbb R$ such that $\lim f_n=f$ pointwise.
This question seems very difficult, maybe because this one is very general, I'm really stuck here, any help is welcome.
Thanks a lot
 A: Take $$f:[0,1]\rightarrow \mathbb{R}\\
f(x)=\left\{\begin{array}{rl} 
0 & x\neq 1 \\
1 &  x=1\\
\end{array}\right. $$
And $$f_n=x^n$$
With scaling and piecewise definitions you can to this one for any countable set of $c_1,\dots ,c_n$
In general our function will look like 
$$f(x)=\left\{ \begin{array}{rl}
0 & x \neq c_i \forall i\\
1 & \text{else} \\
\end{array}\right.$$
On $[c_i,c_{i+1}]$ we gonna have something like 
$$f_{ni}(x)=\left(\frac{c_2-x}{c_2-c_1}\right)^n +\left(\frac{x-c_1}{c_2-c_1}\right)^n$$
And all together we will have (with $I=[a,b]$)
$$f_n(x)=\left\{ \begin{array}{rl}
0 & x\in [a,c_0)\\
f_{ni} & x \in [c_i,c_{i+1})\\
0& x\in [c_n,b] \\
\end{array}\right. $$
Edit for a given function the idea is the following, as you only have finite $c_i$ you take with 
$$\varepsilon=\min_{1\leq i \leq n-1} \{d(c_i,c_{i+1})\}$$
which is the shortest distance between two points of incontinuousity. 
Edit we don't need Stone Weierstraß at all sry.
$[c_i+\frac{\varepsilon}{2n},c_{i+1}-\frac{\varepsilon}{2n}]$ we just take $f$ on the intervalls (the uniform convergence is trivial).  So we only need to chose a secquence of function on $[c_i-\frac{\varepsilon}{2n},c_i+\frac{\varepsilon}{2n}]$. We will call them $s_{ni}$ (like spline).
We chose 
$$s_{ni}(x)= \left\{
 \begin{array}{rl}
f(c_i) + \frac{f\left(c_i-\frac{\varepsilon}{2n}\right)-f(c_i)}{\frac{\varepsilon}{2n}} \cdot (x-c_i) & x-c_i \leq 0\\ 
f(c_i)+\frac{f\left(c_i+\frac{\varepsilon}{2n}\right)-f(c_i)}{\frac{\varepsilon}{2n}}\cdot (x-c_i) & x-c_i >0
\end{array}\right.$$
Ok that one looks really complicated but all i am saying we make a line from the left end to the point we want to have $f(c_i)$ and another one to get a continuous function in all the intervall.
A: The general idea is best explained when there is only one discontinuity point:
Suppose $f$ is continuous for all $x\ne b$. Select two points $a<b$ and $c>b$.  Define the function $g$ by setting $g(x) =f(x)$ for $x\notin (a,c)\setminus\{b\}$,   and on $ (a,c)\setminus\{b\}$, take the graph of $g$ to be piecewise linear. Do this is such a way that $g$ is continuous.
You should draw the picture here. You're just replacing the "discontinuous part" of the graph of $f$ with straight line segments; thus producing a continuous function that agrees with $f$ except on an interval of small length. For the pointwise convergence of the sequence to come, it is important to have $g(b)=f(b)$, here.
By selecting sequences $(a_n)$ and $(b_n)$ with $a_n\nearrow b$ and $c_n\searrow b$, and defining continuous functions $g_n$ as above, one obtains a sequence of continuous functions that converge pointwise to $f$.

If $f$ has finitely many points of discontinuity, $x_1$, $\ldots\,$, $x_k$, do the same thing:
For each $n$, select intervals $O_1$, $\ldots\,$, $O_k$, such that:
$\ \ \ $1) The $O_i$ are pairwise disjoint.
$\ \ \ $2) The sum of the lengths of the $O_i$ is at most $1/n$.
$\ \ \ $3) For each $k$, $x_k$ is the midpoint of $O_k$.
Now define your $f_n$ appropriately.
A: IIRC, it's an issue of whether the convergence of $f_n \rightarrow f $ is uniform, a sufficient condition for the limit function being continuous. If it does (Converge Uniformly), then:
Assume $f_n \rightarrow f $uniformly, so that for some $\delta >0, k> K >0 ; K,k \in \mathbb Z$ , so that for $|x-x_0|< \epsilon, k>K$
$|f(x)-f(x_0)|=|f(x)-f_n(x_0)+ f_n(x_0)-f(x_0) \leq |f(x)-f_k(x))|+|f_k(x)-f_k(x_0)| < \epsilon/2 (*)+ \epsilon/2 (**) = \epsilon$,
Since:
(*) $f_n$ converges uniformly to $f$
(**) The sequence of functions $\{f_n \}$ is continuous
