I am trying to display to codes side-by-side, using this:
\begin{center} \begin{tabular}{c|c} \begin{lstlisting}
while (x > 0) do
x++; \end{lstlisting} & \begin{lstlisting}
x = 0; \end{lstlisting} \end{tabular}\end{center}
Here is what is displayed after compilation: 
The problem is, the vertical line of the tabular goes too far. I have tried to play with the lstlisting parameters belowskip and aboveskip, and tried to use minipages too, but nothing seems to work properly.
My second problem is that using the code above, the second code ("x = 0;") is not aligned with the while.
EDIT : the second issue is solved using minipages, thanks to cfr
Do you know how to solve this ?

minipages or\parboxes with[t]alignment for the second problem. – cfr Jul 30 '15 at 01:51