Show that $\int_{a}^{b}{x^{n}f(x)dx}=0$, then $f=0$ 
Let $f:([a,b],\vert\vert)\to (\mathbb{R},\vert\vert)$ a continuous function. Show that, if $$\int_{a}^{b}{f(x)x^{n}dx}=0$$ for all $n\in\mathbb{N},n\geq 0$, then f is identically zero.

My attempt: Let $A=\{p\in C[0,1]\vert p(x)=a_{0}+a_{1}x+...+a_{n}x^{n}\}$, then $A$ is a algebra of constant functions and separates points. By Stone-Weierstrass theorem, given $\epsilon>0$, exist $p\in A$ such that $\lVert f-p\rVert<\epsilon$ and as $[0,1]$ is compact and $f$ is continuous, exist $M>0$ such that $\vert f(x)\vert\leq M$. So, $$\vert\int_{a}^{b}{f^{2}(x)dx}\vert=\vert\int_{a}^{b}{f(x)(f(x)-p(x))dx}+\int_{a}^{b}{f(x)p(x)dx}\vert$$
$$\leq \int_{a}^{b}{\vert f(x)\vert \vert f(x)-p(x)\vert dx}\leq M\lVert f-p\rVert<\epsilon M$$
$\therefore\int_{a}^{b}{f^{2}(x)dx}=0$, then $f\equiv 0$. So, for what reason if $\int_{a}^{b}{f^{2}(x)dx}=0$, this implies my problem? Thanks
 A: Here is a marginally different approach that I think has a little more intuition.
Since $f$ is continuous, it is bounded by some $B$. Note that $\int f p = 0$
for any polynomial $p$.
Fix $a < a_0 < b_0 < b$, and let $s_n$ be the continuous function formed
by joining the points $(a,0),(a_0,0), (a_0+{1 \over n},1),(b_0-{1 \over n}, 1),(b_0,0), (b,0)$.
Note that $\int |f|\, |1_{[a_0,b_0]}-s_n| \le {2 B \over n}$. 
Let $\epsilon>0$ and choose $n$ such that ${2 B \over n} < {1 \over 2} \epsilon$.
Since the polynomials are dense in $C[a,b]$, we can find a polynomial $p_n$
such that $\|s_n -p_n\|_\infty < {1 \over 2B(b-a)} \epsilon$ and so
$\int |f| |s_n-p_n| < {1 \over 2} \epsilon  $. Then we have
\begin{eqnarray}
\int f 1_{[a_0,b_0]} &=& \int f p_n + \int f(1_{[a_0,b_0]} - p_n) \\
&=& \int f(1_{[a_0,b_0]} - s_n) + \int f(s_n - p_n)
\end{eqnarray}
from which we can see that $|\int f 1_{[a_0,b_0]}| < \epsilon$. Since
$\epsilon>0$ was arbitrary, we have $\int f 1_{[a_0,b_0]}=0$.
If $f(x_0) >0$ then by continuity of $f$, we can find some $a_0,b_0$ such that
$f(x) > {1 \over 2} f(x_0)$ on $[a_0,b_0]$. Then 
$\int f 1_{[a_0,b_0]} > (b_0-a_0) {1 \over 2} f(x_0) >0$, a contradiction.
Similarly if $f(x_0) < 0$. Hence $f(x) = 0$ everywhere.
A: By this hypothesis you have for any polynomial $P$
$$\int_a^b f(x)P(x)\,dx = 0.$$
By Stone-Weierstrass, the polynomials are uniformly dense in $\mathcal{C}[a,b]$.  Therefore,
$$\int_a^b f(x)g(x)\,dx = 0\qquad g\in\mathcal{C}[a,b].$$
Consequently, $f = 0$.
