I would like two side-by-side subfigures, both containing an lstlisting environment. The problem is that using it in the manner shown, I get a left margin from the listing that is redundant, and with long lines is quite wasteful. Any suggestions as to how to do this neatly?
MWE:
\documentclass{article}
\usepackage{subcaption}
\usepackage{listings}
\begin{document}
\begin{figure}
\begin{subfigure}{0.48\textwidth}
\begin{lstlisting}[language=C,frame=single,breaklines=true]
printf("hello world !!!") // This is a long line sort of command and it repeats itself
printf("hello world !!!") // This is a long line sort of command and it repeats itself
printf("hello world !!!") // This is a long line sort of command and it repeats itself
\end{lstlisting}
\caption{Caption a}
\end{subfigure}
\hfill
\begin{subfigure}{0.48\textwidth}
\begin{lstlisting}[language=C,frame=single,breaklines=true]
printf("hello world !!!") // This is a long line sort of command and it repeats itself
printf("hello world !!!") // This is a long line sort of command and it repeats itself
\end{lstlisting}
\caption{Caption b}
\end{subfigure}
\caption{Caption}
\end{figure}
\end{document}

lstautogobblepackage, one could even determine the number of leading spaces automatically: https://tex.stackexchange.com/questions/19953/how-to-automatically-skip-leading-white-spaces-in-listings – Daniel Sep 17 '18 at 16:40