PDA

View Full Version : Using other programs or commands with C?



MiCovran
June 25th, 2007, 09:23 PM
All programming experience I have for now is from algorithm contests, so I don't have great knowledge of C or C++ and absolutely no "real life" experience.
Anyway, I am beginning to make some real console applications (just for education for now) and I was just wondering if there is a simple way to make my program execute another program (eg. cp and mkdir commands, vim, anything).

Thanks.

AlexThomson_NZ
June 25th, 2007, 09:53 PM
Quite simple really, try system("program_name");

rapolas
June 25th, 2007, 10:00 PM
Check here: http://www.gidforums.com/t-3369.html

slavik
June 27th, 2007, 10:55 PM
I reccomend against using system() ... learn fork() and exec() :) (then you can monitor how long the program took and whether it needs to die or some such.