C program to demonstrate the getopt() function
belongs to collection: Command Line Arguments Examples/Programs in C language
All Answers
total answers (1)
belongs to collection: Command Line Arguments Examples/Programs in C language
total answers (1)
The getopt() function is used to extract command line arguments. Here, we are writing a C program to demonstrators the getopt() function.
Program:
The source code to demonstrate the getopt() function is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.
Output:
Explanation:
In the main() function, we used the getopt() function to extract arguments from the command line based on given options and then printed the result on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer