How to write programming code containing the ' character in latex?

Viewed 17357

I am trying to write programming code in latex using the verbatim environment, but when I write

  \begin{verbatim}
     char ch = 'x';
  \end{verbatim}

then the ' -characters around x are displayed incorrectly (they look "curly"). How can I fix this problem?

7 Answers
Related