#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { int opt; int verbose = 0; while ((opt = getopt(argc, argv, "hv")) != -1) { switch (opt) { case 'h': printf("Usage: %s [-h] [-v]\n", argv[0]); printf(" -h Display this help and exit\n"); printf(" -v Increase verbosity\n"); exit(EXIT_SUCCESS); case 'v': verbose = 1; break; default: /* '?' */ fprintf(stderr, "Usage: %s [-h] [-v]\n", argv[0]); exit(EXIT_FAILURE); } } if (verbose) { printf("Verbose mode is on.\n"); } else { printf("Verbose mode is off.\n"); } // Your program's logic goes here return EXIT_SUCCESS; }