Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Designating input and output files in the command line of an executable file

Avatar of SkewdLogix
SkewdLogix asked on
C
8 Comments1 Solution275 ViewsLast Modified:
I have written a program which inputs data from an input file and outputs the resultant solution to an output file. Currently I have the file names hard coded in the body of the program. I need to know how I can enable the program to read from and write to data files of different names which will be supplied by users in the input line of the program executable call. Ideally, I would like to have generic names coded in the program so that they can be associated with the input and output files so many different files can be used.

An example would be:

./program_utilization.exe inputfile outputfile errorfile

Now the user would call the program by issuing the following command:

./program_utilization.exe myinputfile myoutputfile myerrorfile

The program should be able to associate all of the file commands to inputfile/outputfile/errorfile written in the program with the user specified myinputfile/myoutputfile/myerrorfile so that each user would have distinct input and output file names and this process then would enable multiple users at the same time.

I'm not sure how to code this in C. I need to scan the names after the executable call and have them designated as the different files depending on their position and then associated with wildcards written into the program.

Any help would be appreciated.

SkewdLogix
ASKER CERTIFIED SOLUTION
Avatar of ankuratvb
ankuratvbFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answers