21

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

tarabyte
  • 17,837
  • 15
  • 76
  • 117

1 Answers1

41

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
  • 4,286
  • 2
  • 35
  • 59