Question:

Using getopt() function

by Guest45015  |  earlier

0 LIKES UnLike

if i want to open a certain file in C, using optarg

(im using ubuntu)

example: ./program -a file.txt

isn't it that "file.txt" is stored in optarg?

how will i open the real file.txt using optarg?

 Tags:

   Report

1 ANSWERS


  1. Yes, "file.txt" is stored in optarg.  From that point you just need to use the correct optarg value as the file name parameter for the fopen() function.

    The following link shows examples of using fopen():

    http://www.thinkage.ca/english/gcos/expl...

    Look for additional information in my answer to your other question titled "Makefile, getopt() in C..".

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.