Question: gcc -g -o activity activity.c gdb activity run -b bval value watch total continue #include #include #include int main(int argc, char **argv) { extern char

gcc -g -o activity activity.c

gdb activity

run -b bval value

watch total

continue

#include

#include

#include

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;

int bval_int, value_int, total;

static char usage[] = "usage: %s [-r] -b bval 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);

}

/* convert bval and value to integers */

bval_int = atoi(bval);

value = argv[optind];

value_int = atoi(value);

/* calculate the total */

total = bval_int + value_int;

/* print the result */

printf("Total = %d ", total);

exit(0);

}

can someone show me the output just the output i have no way of doing it myself (do not need explanation of the output just the output itself)

PLEASE SHOW ME AN IMAGE OF THE CODE AND THE OUTPUT PLS

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!