Question: Linux C Program gcc Read in command line arguments Task: Read in command line arguments after file.c Utilize getopt() These variables will be filled through

  • Linux C Program gcc

  • Read in command line arguments

  • Task: Read in command line arguments after file.c

  • Utilize getopt()

  • These variables will be filled through command line arguments

  • ex: file.c -a should print out help

  • ex: file.c -b hey create a file named hey

  • ex: file.c -c 5 input 5 is inputted into variable x

  • ex: file.c -d 6 input 6 is inputted into variable xx

  • ex: file.c -e 100 input 100 is inputted into variable xxx

  • ex: file.c [-a] [-b file] [-c x] [-d xx] [-e xxx]

-a prints help

-b file file name to save data to, the default name should be file

-c x x should be an integer, the default should be 3

-d xx xx should be an integer, the default should be 7

-e xxx xxx should be an integer, the default should be 110

Use stderr and perror if other than above is inputted

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!