20

Is there a way to run command line utilities, e.g. gzip, into a C app?

tarabyte
  • 16,086
  • 12
  • 68
  • 106

1 Answers1

37

Use system():

#include <stdlib.h>
int status = system("gzip foo");

See the man page (man 3 system) for more detailed information on how to use it.

By the way, this question already has an answer here: How do I execute external program within C code in linux with arguments?

Community
  • 1
  • 1
jayhendren
  • 3,842
  • 1
  • 32
  • 53