Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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);

}

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

i do not need an explanation of the answer i just want images pls

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_2

Step: 3

blur-text-image_3

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

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions