ProofI will prove a slightly more general results. Suppose
Theorem. If $f\in L^1_{\rm loc}(\Omega)$, $\Omega\subset\mathbb{R}^n$, and $$ \int_\Omega f\phi=0 \quad \text{for all $\phi\in C_c^\infty(\Omega)$}, $$ then $f=0$ a.e.
Proof. Suppose that $f\neq 0$. We can assume $f$ is positive on a set of positive measure (otherwise we replace $f$ by $−f$). Then there is a compact set $K ⊂ \Omega$, $|K| > 0$ and $ε > 0$ such that $f ≥ ε$ on $K$. Let $G_i$ be a sequence of open sets such that $K ⊂ G_i ⊂⊂ Ω$, $|G_i \setminus K| → 0$ as $i → ∞$. Take $ϕ_i ∈ C^∞_0(G_i)$ with $0 ≤ ϕ_i ≤ 1$, $ϕ_i|_K ≡ 1$. Then $$ 0 = \int_Ω fϕ_i ≥ ε|K| − \int_{G_i\setminus K} |f| → ε|K| , $$ as $i → ∞$, which is a contradiction. The proof is complete.