Prove that $g$ is equal to a constant from a given integral. 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... 
 A: 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$.
A: Let $c := \int_0^1 g(x)\, dx$. Then for any $f \in C([0,1])$ we have (as $f - \int_0^1 f(x)\, dx $ has integral 0), 
$$
 \int_0^1 f(x)g(x)\,dx = \int_0^1 \left(\int_0^1 f(y)\,dy\right)g(x)\, dx = c \cdot \int_0^1 f(x)\, dx $$
Let $U \subseteq [0,1]$ be open. There is a sequence of $f_n \in C([0,1])$ converging pointwise to $\chi_U$, applying the above for $f_n$ and taking limits (legit due to Lebesgue's dominated convergence theorem), 
$$ \int_U g(x)\, dx = c \cdot \lambda(U). $$
But now $A \mapsto \frac 1c \int_A g(x)\, dx$ is a measure on $[0,1]$ agreeing with $\lambda$ on the open sets, hence on all measurable sets, giving $c\lambda(A) = \int_A g(x)\, dx$, for all measurable $A$.
Now for $\epsilon > 0$: 
$$ c \lambda(\{g > c+\epsilon\}) = \int_{\{g > c+\epsilon\}} g\, dx \ge (c+ \epsilon)\lambda(\{g > c+\epsilon\}) $$ 
hence $\lambda(\{g > c +\epsilon\}) = 0$. As $\epsilon > 0$ was arbitrary, $g \le c$ almost everywhere. Considering $\{g < c - \epsilon\}$ and arguing as above, shows $g = c$ almost everywhere.
A: Take any $\phi\in C_0^1(0,1)$. Note that $\phi'\in C_0(0,1)$ and $$\int_0^1\phi'(x)=\phi(1)-\phi(0)=0$$
hence, $$\int_0^1g(x)\phi'(x)=0,\ \forall\ \phi\in C_0^1(0,1)\tag{1}$$
Consider a function $\psi\in C_0(0,1)$ such that $\int_0^1\psi=1$. For any $w\in C_0(0,1)$ consider the function $$h=w-\left(\int_0^1 w\right)\psi$$
Note that $h$ is continuous, it has compact support in $(0,1)$ and $\int_0^1 h=0$. If follows from this analysis that for each such $w$, there is $\phi\in C_0^1(0,1)$ with $$\phi'=h$$
We conclude fomr $(1)$ that $$\int_0^1 g\left(w-\left(\int_0^1 w\right)\psi\right)=0,\ \forall w\in C_0(0,1)$$
or equivalently
$$\int_0^1 \left(g-\left(\int_0^1 g\psi\right)\right)w=0,\ \forall w\in C_0(0,1)$$
Now you can apply the fundamental lemma of calculus of variations to conclude that $$g=\int_0^1 g\psi$$
Remark: See lemma 8.1 of Brezis.
