# Can I enter code directly from a source file?

In a project I'm working, all the files are in the same folder (source codes, papers, images, etc).

In the documentation, I'm including some code with minted which is really great, but I want to do something like this:

\begin{minted}{c}
\input{main.c}
\end{minted}


I know that won't work, but you can see what I want to do. The reason for this, is because I don't want to update documentation every time I change a source file, do you understand? The idea is to leave main.c as it is, and include that file automatically in the documentation.

-

Try \inputminted{c}{main.c} or generally \inputminted[options]{language}{filename} -- see page 4 of the minted manual.

-
That happens to me bacause of the fast-manual reading :S –  Tomas Nov 8 '10 at 7:14

I have used listings in the past and am pleased with the results. It support several different programming languages, and is simple, yet powerful:

\lstset{language=C}
\input{funkyalg.c}

-
Listings is great, but IMO it isn't as powerful as minted. Because minted relays on pygmentize to make the sintax. –  Tomas Nov 8 '10 at 15:54

You might consider \usepackage{fancyvrb}. It lets you do simple things like \VerbatimInput{hello.c} or fancy things like
\fvset{frame=single,numbers=left,numbersep=3pt} \VerbatimInput{hello.c} (see page 20 of the manual).

-