[Tex/LaTex] How to lstinput a text file path and get content of ext file into pdf

listings

I tried to insert some data using listings package labels(lstset) into pdf which was successful but if the same data is put into a text file ans lstinput it as follows is not successful .Can some one please make the following non-working example work.

\documentclass{report}
\usepackage{listings}

\lstset{basicstyle=\footnotesize\ttfamily,breaklines=true}
\lstset{framextopmargin=50pt,frame=bottomline}


\begin{document}

\begin{lstlisting}

\lstinputlisting{C:/Temp/test.txt}


\end{lstlisting}


\end{document}

OUTPUT:

\lstinputlisting{C:/Temp/test.txt}


Also the contents in test.txt IS AS FOLLOWS

include

main()
{

print "HELLO";
}

Best Answer

The \lstinputlisting instruction replaces a lstlisting environment. With your input, you are asking not to interpret \lstinputlisting.

\documentclass{report}
\usepackage{listings}

\lstset{basicstyle=\footnotesize\ttfamily,breaklines=true}
\lstset{framextopmargin=50pt,frame=bottomline}


\begin{document}

\lstinputlisting{C:/Temp/test.txt}

\end{document}
Related Question