I want to show some program code line by line. I have the following code:
\documentclass[10pt,english]{beamer}
\usepackage{listings}
\lstset{
language=C,
basicstyle=\ttfamily
}
\begin{document}
\begin{frame}[fragile]
\frametitle{Slides with code}
\begin{itemize}
\item <1-> A piece of code
\item[] <2-> \begin{lstlisting}[caption=,belowskip=-5pt]
int main(void)
\end{lstlisting}
\item[] <3-> \begin{lstlisting}[caption=,belowskip=-5pt]
{
\end{lstlisting}
\item[] <4-> \begin{lstlisting}[caption=,belowskip=-5pt]
int i;
\end{lstlisting}
\end{itemize}
\end{frame}
\end{document}
Now this is error-prone a painstaking. Is there another way to produce these slides?

\pauseon each line, but it's better than having to restart the listing every time. – Teepeemm Sep 27 '21 at 15:54