How Do I Incorporate C Code or External Programs in Mathematica?
Mathematica can communicate with external programs through operating systems that support interprocess-communication mechanisms such as pipes. In the simplest cases, the only communication you need is to send and receive plain text. In general, Mathematica allows you to treat streams of data exchanged with external programs just like files. In place of a file name, you give the external command to run, prefaced by an exclamation point.