TITLE: Prove that $g$ is equal to a constant from a given integral.
QUESTION [7 upvotes]: Suppose $g : [0,1] \rightarrow \mathbb{R}$ is bounded and measurable and 
$$
\int_{0}^{1}f(x)g(x)dx = 0
$$
whenever $f$ is continuous and $\int_{0}^{1}f(x)dx = 0$. Prove that $g$ is equal to a constant a.e

How do I solve it? I tried integration by parts, but it didn't work...

REPLY [2 votes]: Using $f-\int f$, the condition in the question can be phrased as saying that
$$
\int fg=\int f\,\int g
$$
for all continuous $f$. Using the fact that continuous functions are dense in $L^1$, we get that the equality above holds for any integrable $f$. In particular,
$$
\int g^2=\left(\int g\right)^2.
$$
Then 
$$
\left|\int g\right|^2=\int1^2\,\int g^2.
$$
Thus we have equality in Schwarz inequality, implying that $1$ and $g$ are linearly dependent. That is, $g=c$ for some $c\in\mathbb R$.