$C([0,1])$ is separable: Is my solution correct? Claim: $C([0,1])$ is separable w.r.t. the supremum norm.
My solution: We want a countable subset $M$ s.t. $\forall f \in C([0,1])$ it exists a $g_n\in M $ s.t. $\lim_{n\to\infty}\Vert g_n-f \Vert_{\infty}=0$.
So I construct the countable subset as following:
\begin{equation}
M:=\{g_n:[0,1]\to [0,1] : g_n=f\mathbb{1}_{[1/n,1-1/n]} \text{ with } n\in \mathbb{Q}, f\in C([0,1])\}
\end{equation}
and so we can show that for every $f\in C([0,1])$ it exists $g_n\in M$ s.t. $\lim_{n\to \infty} \Vert g_n-f\Vert$=0.
I've read many solutions, all showing that $\mathbb{Q}_{[0,1]}$ is (by Bolzano-Weierstrass) dense in $\mathbb{R}_{[0,1]}$. But I'm wondering why my solution should not work? Thank you for your help.
 A: The easiest route that I know to this result is the Weierstrass approximation theorem: Polynomials are dense in $C[0,1].$ It follows that the set of polynomials with rational coefficients is dense in $C[0,1].$ The latter set is countable. Perhaps Weierstrass is not on the table here.
A: I think the easiest way to see that $C[0,1]$ is separable is to take the countable set $F=\cup_{n\in N}F_n,$ where $F_n$ is the family of all  $f\in C[0,1]$ that satisfy :
(i). $f(j/n)\in Q$ for integer $j \;(0\leq j \leq n).$
(ii). For integer $j$ with $0\leq j<n,$ the function $f$ is linear on the interval $[j/n,(j+1)/n].$
Any $g\in C[0,1]$ is uniformly continuous. So for  $g\in C[0,1]$ and  $r>0,$ let $n\in N$ be large enough that $|x-y|\leq 1/n\implies |g(x)-g(y)|< r/5 $ for all $x,y \in [0,1]$ .  Take $f\in F_n$ satisfying  $|f(j/n)-g(j/n)|<r/5$  for each integer $j \;(0\leq j \leq n).$
For $0\leq j<n$ and $x\in [j/n,(j+1)/n]$ we have $$|g(x)-f(x)|\leq |g(x)-g(j/n)|+|g(j/n)-f(j/n)|+|f(j/n)-f(x)|<$$ $$ <r/5+r/5+|f(j/n)-f(x)|\leq$$ $$\leq  2r/5+|f(j/n)-f((j+1)/n)|$$  because $f$ is linear on $[j/n,(j+1)/n]$. And since $$|f(j/n)-f((j+1)/n)|\leq$$ $$\leq |f(j/n)-g(j/n)|+ |g(j/n)-g((j+1)/n)|+|g((j+1)/n)-f((j+1)/n)|<$$ $$<r/5+r/5+r/5.$$  So we have $$|g(x)-f(x)|<r.$$ 
