1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tensa zangetsu [6.8K]
4 years ago
15

Suppose that a function dynamically allocates a block of memory with a local pointer variable p pointing to the allocated block.

Suppose further that there are no other pointers referencing that block of memory, and the function returns without doing a delete on p. Then
A.
the pointer p becomes a dangling pointer.

B. the compiler will automatically deallocate the memory pointed to by p.

C. the program will suffer from memory leaks.

D. the returning function will throw the bad_alloc exception.

E. None of these
Computers and Technology
1 answer:
Kaylis [27]4 years ago
6 0

Answer:

The Pointer P becomes a dangling pointer.

Explanation:

int calculate(){

int *p = (int*)malloc(10);

*p = 10;

return p;

}

In this program, the scope of p is only with the calculate function block. Hence, once the compiler comes out of the function, it can no more access the pointer p or the memory location p is pointing to. To overcome the dangling pointer, we need to declare p as static, so that the scope of p is throughout the program.

You might be interested in
A(n) is a list of commands that tell your computer what to do.
Leviafan [203]
A program is a list of commands that tell your computer what to do<span />
7 0
3 years ago
Read 2 more answers
To protect yourself from the risk of product failure, what strategy could you use?
Sloan [31]

I would move the file into a folder and zip it or move the it into a flash drive

5 0
3 years ago
he wants to customize the operating system to meet his needs. what types of tools should he use, and what can he do with each?
Dennis_Churaev [7]

Answer:

remastering iso image

Explanation:

you  can add the gui, default installed program, etc

3 0
3 years ago
Match these step-by-step directions in the order that you will find them in this course.
7nadin3 [17]

Answer:

1.Go to the View tab and select Watch.

2.Comparison

3.Editing

4.Drawing (I think)

5.Predesigned slides available for creating a new presentation

Explanation:

6 0
3 years ago
What may happen if a large number of computer users are attempting to access a web site at the same time that you are?
Maurinko [17]
A. You may be unable to link to the site.
<span />
4 0
3 years ago
Other questions:
  • The goal of conducting an incident analysis is to ascertain weakness. Because each incident is unique and might necessitate a di
    8·1 answer
  • A student is searching through a large box of unused cables and connectors in the classroom. The student finds a ribbon with con
    14·1 answer
  • You can decide if a paint booth filter is hazardous waste by answering which of the following questions: A) Is the paint residue
    12·2 answers
  • Explain The Two Way Communication in full.
    10·1 answer
  • Citing Wikipedia as a reference is not considered a good practice because 1.leverages a neutral point of view. 2.hosts unopinion
    8·1 answer
  • Company Wizzy is having trouble with network security. Issues with authentication, viruses, malware/spyware, and other network i
    12·1 answer
  • Write the program to accept the radius of circle and find its diameter coding
    11·1 answer
  • What will be the output of the following code segment:
    12·1 answer
  • Which shortcut keys can be used to duplicate a slide?
    15·1 answer
  • Which element of the MakeCode Arcade interface represents an individual
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!