The following code is meant to prompt you for integer input from the keyboard, read your input, and display it on the screen. The program compiles, but doesn’t work properly. Use gdb to find the bugs in the program. What are they? Fix the bugs, recompile the program, and execute it to be sure that the corrected version works. Show the working version of the program.

What will be an ideal response?


```
#include
#define PROMPT "Enter an integer: "
void get_input(char *, int *);
void main ()
{
int *user_input;
get_input(PROMPT, user_input);
(void) printf("You entered: %d.\n", user_input);
}

void get_input(char *prompt, int *ival)
{
(void) printf("%s", prompt);
scanf ("%d", ival);
}
```
The pointer user_input is being printed without dereferencing it.
```
#include
#define PROMPT "Enter an integer:"
void get_input(char *, int*);

void main()
{
int *user_input;
get_input(PROMPT,user_input);
(void) printf("You entered: %d.\n",*user_input);
}
void get_input(char *prompt, int *ival)
{
(void) printf("%s",prompt);
scanf("%d",ival);
}
```

Computer Science & Information Technology

You might also like to view...

The dodge-based or lightening blending modes, including ____, react differently for colors on either side of the 50 percent gray threshold.

a. threshold b. vivid c. hard d. linear

Computer Science & Information Technology

x = (0, ?1, 0, 1), y = (1, 0, ?1, 0) cosine, correlation, Euclidean

For the following vectors, x and y, calculate the indicated similarity or dis- tance measures.

Computer Science & Information Technology

____ and quantitative assessments of performance are critical to making intelligent management decisions.

A. Tangible observation B. Indirect observation C. Direct control D. Indirect management

Computer Science & Information Technology

You can save a single worksheet as a webpage, where Excel changes the content of the worksheet into ________, a language web browsers can interpret

Fill in the blank(s) with correct word

Computer Science & Information Technology