October 28, 2024
Chicago 12, Melborne City, USA
C++

Passing Parameters to a .c executed with execl in C


In C, if I use the execl command to execute another .c file, is there a way to pass parameters to this file that it can use during execution?

In my problem, I have C code that uses execl to execute an additional .c script. Once this script completes execution and returns its output (written to a file for context), control returns to the main file.

To avoid issues with the second script reading files, I’d like to perform as many operations as possible in the main code and then pass only the results to the second process via parameter passing. Is there a way for these two pieces of code to communicate?

execl("./script", "script", argcv[i], NULL);



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video