[Tex/LaTex] How to set a background color for a listing

backgroundscolorlistings

enter image description here
Someone who knows how to fill with color only the box?

\begin{shaded} 
\begin{lstlisting}

if (a < b)
 {
    printf("A is smaller than  B!\n");
 }
 a = b;

\end{lstlisting}
\end{shaded}

Best Answer

listings has a setting backgroundcolor=\color{gray} for this purpose:

\lstset{backgroundcolor=\color{gray}}
\begin{lstlisting}

if (a < b)
 {
    printf("A is smaller than  B!\n");
 }
 a = b;

\end{lstlisting}

See section 2.7 of the manual which you should get with texdoc listings.