views:

132

answers:

2

How do I execute another program from within a C program in Windows 32 - in a similar way as Perl's system() function or Python's sub-process module - such as DEL, REG, or other cmd.exe programs?

+2  A: 

C does have a system function in its standard library, see e.g. the wikipedia entry about it.

Alex Martelli
Wow, I didn't think that such a low-level (and somewhat old) language would still have a system() function just like higher-level languages such as Perl.
Bushman
If I had to guess, I'd say perl's system derives from C's.
WhirlWind
Now that I think about it, and also that I compare C's control-flow statements and variable typing to that of Perl, Mr. Wall was quite clever in making Perl's syntax so similar to C's (easier to compile into C). Which confuses me even more why I can't find anything to convert perl code into a nice stand-alone, no-interpreter-included, fully Windows-compatible, .c source.
Bushman
A: 

You can use: system():, popen(), CreateProcess(), maybe even others. Just search for them in http://msdn.microsoft.com.

vanza