Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call command line from C program

Tags:

c

command-line

I am writing an command line application in C and from within the program, I would like to call other command-line applications. For example (and only as a clear example!), say the I would like to write a C app that calls the java compiler. For one, how would I do this? Is there a C function that directly calls the command line of something? For two, how would I take the normal text output that the java compiler displays and display it through the c program?

I'm sorry if this sounds a bit crazy, but I am very new to C and I have never done anything like this before. I would love to start writing a few of these utility style apps. If it matters any, I am currently running Windows, but would prefer a platform-independent method if possible, as I do use Linux from time to time.

like image 640
Jason Watkins Avatar asked Dec 03 '10 03:12

Jason Watkins


1 Answers

You might look into system. I think you can use it in Windows as well as UNIX/Linux systems.

like image 193
Fred Larson Avatar answered Oct 07 '22 22:10

Fred Larson