Integral of monomial times a function is zero

Let $f$ be a continuous function on $[a,b]$ such that $\int_a^bx^nf(x)dx=0$ for all nonnegative integer $n$. Prove that $f(x)=0$ for all $x\in[a,b]$.

The equation tells us that $\int_a^bp(x)f(x)dx=0$ for all polynomials $p$. I was thinking to choose a nonzero polynomial $p$ such that $p(x)f(x)\ge0$ for all $x\in[a,b]$. However this is apparently impossible if $f$ has infinitely many roots. Then I tried to make $p(x)f(x)$ very large in some interval, and very small in the other intervals. Again this does not seem to work if the roots of $f$ is dense in $[a,b]$.

Edit: Okay, so I now know that the roots of $f$ cannot be dense in $[a,b]$ (otherwise $f$ is constant and we're done). Now $f$ is positive (wlog) in some interval $[c,d]$. I want $p(x)$ to be a polynomial such that $p(x)f(x)$ is very large in $[c,d]$ and very small elsewhere. I'm definitely sure that such a polynomial exists, but don't know how to prove it. Can my idea be finished?

-
If the roots of $f$ are dense in $[a,b]$ and $f$ is continuous... – Brandon Carter Nov 12 '11 at 15:07
Oh right! That implies that $f$ is constant! Thanks! – user19322 Nov 12 '11 at 15:09
This question is a duplicate of math.stackexchange.com/questions/16831/… – mt_ Nov 12 '11 at 19:23

The polynomials are dense in $C([a,b])$. Thus you can choose a sequence of polynomials $p_n$ such that $p_n(x) \to f(x)$ uniformly on $[a,b]$. Then $$0 = \lim_{n \to \infty} \int_a^b p_n(x) f(x) dx = \int_a^b f^2(x) dx.$$
Sorry, this is beyond what I've learned so far. Can you explain the definition of dense set in $C([a,b])$? Does that mean that for any $f,g\in C([a,b])$, there exists a polynomial $p$ such that $f(x)\le p(x)\le g(x)$? Also, what do you mean by $p_n(x)\to f(x)$ uniformly? – user19322 Nov 12 '11 at 15:18
You can define a norm on $C([a,b])$ by setting $\|f\| = \sup_{x \in [a,b]} f(x)$. This norm defines a topology in $C([a,b])$. A set $P$ is dense if for every open set $U$ we have $U \cap P \neq \emptyset$. In this case it is equivalent to stating that for any $f \in C([a,b])$ there is $p \in P$ such that $\|f - p\| \le \epsilon$. Uniform convergence means that $\|f - p_n\| \to 0$ as $n \to \infty$. – J. J. Nov 12 '11 at 15:23