How to read the Values of argc and argv in main function (c) from file?

78 Views Asked by At

I want for main function in c program, read argc and argv from file.

How to read argv and argc from file in C language?

For example:

./prog --test=cpu --prime=1000 run 

Change to:

./prog file.txt

File.txt is:

--test=cpu --prime=1000 run

Prog is a very big program.

1

There are 1 best solutions below

4
Paul R On

You don't need to change the program, you can just do something like this:

./prog $(cat file.txt)

(assumung bash or similar shell).