I will leave this problem to grade to Prof. Colliander. None of the posted solutions satisfies me.
Proof. Consider
\begin{equation}
g(x)=\sum_{n=-\infty}^\infty nc_n e^{inx}.
\label{eq-1}
\end{equation}
Since $\sum_{n=-\infty}^\infty |nc_n e^{inx}|=\sum_{n=-\infty}^\infty |n|\cdot |c_n|\le M$, series (\ref{eq-1}) converges uniformly and therefore one can integrate it termwise:
\begin{equation}
\int_0^x g(x)\,dx=\sum_{n=-\infty}^\infty \int_0^x nc_n e^{inx}\,dx =\sum_{n=-\infty}^\infty \int_0^x c_n \bigl(e^{inx}-1)=f(x)-f(0)
\label{eq-2}
\end{equation}
Therefore $f(x)$ is differentiable and $f'(x)=g(x)$.
PS. You can differentiate series termwise if you get uniformly converging series. Nobody mentioned this.