[Tex/LaTex] How to align left and right on the same lines

codehorizontal alignmenttables

the first c program

I'm trying to create something similar to this, but I am having trouble
getting it to work. I have tried using the tabular environment, but i get
an "overfull hbox". I have also used tabulary and \hfill.
\hfill seems like what I want, but I am having trouble using it across
multiple lines. What would be the best way to implement something like the picture in LaTeX?

Here is what i have tried so far:

\verb|#include <stdio.h> \hfill \verb{include information about standard library}
\verb|main| \hfill \emph{define a function named} \verb|main| \emph{that receives no argument values}

and so on, but once the italic text on the right gets too long, it starts
to align against the left margins.

Best Answer

Here is a suggestion using listings.

\documentclass{article}
\usepackage{listings}
\lstset{
  language=C,
  frame=tb,
  escapeinside={@:}{:@},
  showstringspaces=false,
  basicstyle=\ttfamily
}

\newcommand\Comment{\hfill\normalfont\itshape}
\begin{document}

\begin{lstlisting}[caption={First C code}]
#include <stdio.h> @:\Comment include information about standard library:@

main() @:\Comment define a function named \texttt{main} :@
@:\Comment that receives no argument values :@
{
    printf("hello world\n");
}

\end{lstlisting}
\end{document}

enter image description here