Let $f\in L^2$ how can I show that for all $\varepsilon>0$ there is $g$ continuous with compact support s.t. $\int (f-g)^2<\varepsilon$ ?
I know that $f\in L^2\implies f^2\in L^1$ and since the function continuous with compact support is dense in $L^1$, if $\varepsilon>0$ there is $g$ continuous with compact support s.t. $\int |f^2-g|<\varepsilon $.
After, I don't know how to continue.
Let $K$ be the Hilbert subspace of $L^2$ generated by the continuous compactly supported functions, i.e., the closure of their linear span. This space includes the indicator functions of finite intervals $[a,b]$; this follows from the existence, for arbitrarily small $\epsilon>0,$ of a continuous function $\phi_\epsilon$ that is identically $0$ outside $(a-\epsilon,b+\epsilon),$ identically $1$ on $[a,b]$ and between $0$ and $1$ in the margins.
Let $f_1$ be the orthogonal projection of $f$ on $K.$ Then $f-f_1$ is orthogonal to all indicators of intervals so it must be zero almost everywhere. This implies $f\in K,$ in other words $f$ is an $L^2$ limit of linear combinations of continuous compactly supported functions; note that these linear combinations are themselves continuous and compactly supported.