Zahra Heydari
Zahra Heydari

Reputation: 55

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

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.

Upvotes: 0

Views: 82

Answers (1)

Paul R
Paul R

Reputation: 212949

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

./prog $(cat file.txt)

(assumung bash or similar shell).

Upvotes: 3

Related Questions