If $f$ is continuous on $[a , b]$ and $\int_a^b f(x) p(x)dx = 0$ then $f = 0$

Show that if $f$ is a continuous function on the interval $[a , b]$ and if $\int_a^b f(x) p(x)dx = 0$ for every polynomial $p$ then $f$ must be the zero function.

Attempt:

By the Weierstrass Approximation Theorem, we know there is a sequence $\{p_j\}$ such that $p_j \rightarrow f$ uniformly on $[a,b]$. (The Theorem states: "Let $f$ be a continuous function on an interval $[a,b]$. Then there is a sequence of polynomias $p_j(x)$ with the property that the sequence $p_j$ converges uniformly on $[a,b]$ to $f$.")

Then since $p_j$ is integrable on $[a,b]$ and since $p_j \rightarrow f$ uniformly on $[a,b]$. Then we know $f$ is integrable on $[a,b]$ and $\lim_{j \to \infty} \int_a^b p_{j}(x) dx = \int_a^b f(x) dx$.

But how do I know $f(x) = 0$ ?

-
@David: Thanks for that example. I deleted my answer. – Patrick Mar 3 '12 at 21:01
Hint: $\int_a^b f(x) p_j(x) \, dx = 0$ by assumption, and by uniform convergence $\int_a^b f(x)^2 \, dx = 0$. Can you finish from here? – Qiaochu Yuan Mar 3 '12 at 21:08

You have to use that $0=\int fp_j\rightarrow \int f^2$ which implies that $f\equiv 0$ since $f$ is continuous.
So then... Putting everything together... Since $f$ is continuous, by Weierstrass Approximation Theorem, we know there is a sequence $\{p_j\}$ such that $p_j \rightarrow f$ uniformly on $[a,b]$. Then, since $p_j \rightarrow f$ uniformly on $[a,b]$, it follows that $f p_j \rightarrow f^{2}$ uniformly on $[a,b]$. Then, $\lim_{j \to \infty} \int_a^b f(x) p_{j}(x) dx = \int_a^b f^{2}(x) dx$. And by assumption, $\int_a^b f(x) p(x) dx = 0$ for any polynomial $p$. So, $\int_a^b f^{2}(x) dx = 0$. And since $f$ is continuous, we know $f = 0$. Look alright? – Jason P. Mar 3 '12 at 22:21
How you explain this: $\lim_{j \to \infty} \int_a^b f(x) p_{j}(x) dx = \int_a^b f^{2}(x) dx$, how the limit get inside the integral? – Salech Alhasov Mar 4 '12 at 3:56
That convergence $p_j\rightarrow f$ is uniform then we have $fp_j\rightarrow f^2$ uniformly. – checkmath Mar 4 '12 at 12:46
A more direct (but less clever and less elegant) solution is to suppose $f(c) \neq 0$. Then $f(x) \neq 0$ on a small interval around of $c$. Choose $p$ so that it's very small outside of that interval and very large inside that interval, and get a contradiction.