\documentclass[12pt,a4paper]{article}

\usepackage{listings}
\lstset{language=C}


\begin{document}

\begin{lstlisting}

#include <stdio.h>

int main(void)
{
  int c;

  while ((c = getchar()) != EOF)
    putchar(c);
    return 0;
}

\end{lstlisting}


\end{document}