Boundedness of one-dimensional Sobolev functions

This is a special case of Theorem 7.34 from G. Leoni's 'A First Course in Sobolev Spaces', Second Edition. I'll give the proof of what you want; it already contains the main steps to prove the full Theorem.

For $p=\infty$, the conclusion is contained in the assumptions. For $p<\infty$, By a similar proof to the following link, $C^\infty_c$ functions are dense in $W^{1,p}(\mathbb R)$:

$C^1_c$ functions are dense in Sobolev space

So lets assume $f$ is in $C^\infty_c$. Let $\ell>0$, let $x\in\mathbb R$ be arbitrary and consider the interval $I_x=(x-\ell/2,x+\ell/2)$. By the continuity of $f$, there is $x_1\in \overline{I_x}$ such that $|f(x_1)|=\inf_{\tilde x\in I_x} |f(\tilde x)|$. Then $$f(x) = f(x_1) + \int_{x_1}^x f'(y)dy$$ so that $$ |f(x)| \le \frac{1}{\ell} \int_{I_x} |f(y)|dy + \int_{I_x} |f'(y)|dy \le \ell^{-1/p}\|f\|_{L^p(\mathbb R)} + \ell^{1-1/p} \|f'\|_{L^p(\mathbb R)}.$$ Since $x$ is arbitrary, this proves that any $f\in W^{1,p}(\mathbb R)$ is indeed bounded.

One can choose $\ell$ so that the two terms have equal contribution i.e. $$ \ell^{-1/p}\|f\|_{L^p(\mathbb R)} = \ell^{1-1/p} \|f'\|_{L^p(\mathbb R)} \iff \ell = \frac{\|f\|_{L^p(\mathbb R)}}{\|f'\|_{L^p(\mathbb R)}}$$ which leads to the following special case of the very useful Gagliardo-Nirenberg interpolation inequality -

$$ \|f\|_{L^\infty(\mathbb R)} \le 2 \|f'\|_{L^p(\mathbb R)}^{1/p}\|f\|_{L^p(\mathbb R)}^{1-1/p}$$