Showing a function is constant given a condition on an integral Suppose $h : [a,b]\to\mathbb{R}$ is a continuous function and
$$ \int_{a}^{b}h(x)g'(x)dx = 0$$ 
for all $g \in \mathcal{C}^{1}[a,b]$ with $g(a) = g(b) = 0$. Show that $h$ must be a constant function.
I have used integration by parts to achieve
$$ 0 = \int_{a}^{b}h(x)g'(x)dx = -\int_{a}^{b}h'(x)g(x)dx $$
but am not sure what this means or if it is even a relevant approach. I look forward to any hints or tips.
 A: Since $h\in C[a,b]$, then it is integrable on $[a,b]$.  Let $\phi(x)$ be the function 
$$\phi(x)=\int_a^x h(t)\,dt-\frac{(x-a)}{b-a}\int_a^bh(t)\,dt$$
Then, $\phi\in C^1[a,b]$ and $\phi(a)=\phi(b)=0$.  
In addition, we have $\phi'(x)=h(x)-\frac{1}{b-a}\int_a^b h(t)\,dt$.  
Therefore, since we have $\int_a^b h(x)g'(x)\,dx=0$ for all $g\in C^1[a,b]$ with $g(a)=g(b)=0$, then we may select $g(x)=\phi(x)$ and write
$$\begin{align}
\int_a^b h(x)g'(x)\,dx&=\int_a^b h^2(x)\,dx-\frac{1}{b-a}\left(\int_a^b h(x)\,dx\right)^2\\\\
&=0
\end{align}$$

But from the Cauchy-Schwarz inequality, 
$$\left(\int_a^b h(x)\,dx\right)^2\le (b-a)\int_a^b h^2(x)\,dx $$
with equality holding if and only if $h(x)$ and $1$ are linearly dependent, which implies here that $h$ is constant.
And we are done!
A: Let's choose a function $g$ such that $$g'(x) = h(x) -  k$$ for some suitably chosen constant $k$ such that $g(a) =g(b) =0$. Then we can see that $$\int_{a}^{b} (h(x) - k) ^{2}\,dx=\int_{a}^{b}h(x)g'(x)\,dx - k\int_{a} ^{b} g'(x) \, dx = 0$$ It now follows from continuity of $h(x) $ that $h(x) = k$ for all $x\in[a, b] $. 
The proof is now complete if we can choose a constant $k$ meeting the requirement $g(a) =g(b) =0$. Clearly we can take $$g(x) =\int_{a} ^{x} h(t) \, dt -  kx + c$$ and then solve for $k, c$ using $g(a) = g(b) = 0$. We get $$ka=c, kb=c+\int_{a} ^{b} h(t) \, dt$$ so that $$k=\frac{1}{b-a}\int_{a}^{b}h(t)\,dt,c=\frac{a}{b-a}\int_{a}^{b}h(t)\,dt$$ and hence $$g(x) =\int_{a} ^{x} h(t) \, dt - \frac{x-a} {b-a} \int_{a} ^{b} h(t) \, dt$$ This explains the genesis of the function $\phi(x) $ of Dr. MV's answer. 
