Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

makefile activity: activity.c gcc -o activity activity.c clean: rm -f activity #include #include #include int debug = 0; int main(int argc, char **argv) { extern

makefile

activity: activity.c gcc -o activity activity.c

clean: rm -f activity

#include #include #include

int debug = 0;

int main(int argc, char **argv) { extern char *optarg; extern int optind; int c, err = 0; int rflag=0, bflag=0; char *bval = "default_bval", *value; static char usage[] = "usage: %s [-r] -b bval value [value ...] ";

while ((c = getopt(argc, argv, "rb:")) != -1) switch (c) { case 'r': rflag = 1; break; case 'b': bflag = 1; bval = optarg; break; case '?': err = 1; break; } if (bflag == 0) { /* -b was mandatory */ fprintf(stderr, "%s: missing -b option ", argv[0]); fprintf(stderr, usage, argv[0]); exit(1); } else if ((optind+1) > argc) { /* need at least one value */

fprintf(stderr, "%s: missing value ", argv[0]); fprintf(stderr, usage, argv[0]); exit(1); } else if (err) { fprintf(stderr, usage, argv[0]); exit(1); } /* see what we have */ printf("rflag = %d ", rflag); printf("bval = \"%s\" ", bval); if (optind < argc) /* these are the values after the command-line options */ for (; optind < argc; optind++) printf("value: \"%s\" ", argv[optind]); else { printf("no values left to process "); } exit(0); }

whats the output of this

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

Students also viewed these Databases questions

Question

1. Design an effective socialization program for employees.

Answered: 1 week ago