Let $C^1_c(\mathbb{R})$ be the set of compactly-supported continuously-differentiable complex-valued functions on the real line, and let $H^1(\mathbb{R})$ be the Banach space consisting of functions $f\in L^2(\mathbb{R})$ satisfying $$ ||f||^2_{H^1(\mathbb{R})} := \int_\mathbb{R} (1+|\xi|^2)|\widehat{f}(\xi)|^2d\xi < \infty,$$ where $\hat{f}(\xi)=\int_\mathbb{R} e^{-2\pi ix\xi}f(x) dx$ is the Fourier transform of $f$. Notice $C^1_c(\mathbb{R})\subset H^1(\mathbb{R})$ because if $f\in C^1_c(\mathbb{R})$ then $||f||_{L^2(\mathbb{R})}^2 + ||f'||_{L^2(\mathbb{R})}^2= ||f||^2_{H^1(\mathbb{R})}$ by Plancherel's Theorem and using $\widehat{f'} = i\xi\widehat{f}$.
How can we prove that $C^1_c(\mathbb{R})$ is dense in $H^1(\mathbb{R})$?
Two step proof - approximate $f$ with a compactly supported function $\tilde f$, then mollify to approximate $\tilde f$.
It is easy to check that multiplying a $H^1(\mathbb R)$ function $f$ by a $C^\infty_c(U)$ function $\zeta$ gives a $H^1$ function $f\zeta$ supported on the support of $\zeta$. We can choose a family for $R>0$, $\zeta_R\in C^\infty_c(U)$ such that \begin{align}0\le \zeta_R\le 1\\ \zeta_R(x) = 1 &\quad |x|<R\\ |\zeta_R'| \le 1 \\ \zeta_R(x)=0 &\quad |x|>3R \end{align} We have as $R\to\infty$, $$ \|f-f\zeta_R\|_{L^2(\mathbb R)} \le \|1-\zeta_R\|_{L^\infty}\|f\|_{L^2(|x|>R)} \le \|f\|_{L^2(|x|>R)} \to 0 $$ and $$ \|(f-f\zeta)'\|_{L^2(\mathbb R)} \le \|f' - f'\zeta_R\|_{L^2(\mathbb R)} + \|f\zeta_R'\|_{L^2(R<|x|<3R)} \to 0$$ the first term like the first calculation, and the second term by similar reasoning (just note $\|f\zeta_R'\|_{L^2(R<|x|<3R)} \le \|f\|_{L^2(|x|>R)}\to 0$). So there exists $\tilde f\in H^1(\mathbb R)$, an open bounded set $U$, and a compact subset $K\Subset U$ such that $\tilde f$ is supported in $K$ and $$ \|f-\tilde f\|_{H^1(\mathbb R)} \le \epsilon .$$
Now take your standard mollifier $\eta_\delta$, $\delta>0$ and convolve with $\tilde f$ to get $f_\delta = \tilde f * \eta_\delta$. Its standard / easy to check that $f_\delta \in C^\infty_c(U)$ for sufficiently small $\delta< \delta_0$, and they are all supported inside a common compact set $F$ (where $K \subset F\Subset U$) and as $\delta\to 0$, we have $$f_\delta \to \tilde f\text{ in }H^1(F).$$ As $f_\delta$ and $\tilde f$ are zero outside $F$, this also means that $$f_\delta \to \tilde f\text{ in }H^1(\mathbb R).$$
Putting the two together proves that $C^\infty_c(\mathbb R) \subset C^1_c(\mathbb R) $ is dense in $H^1(\mathbb R)$.