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
Which route of entry could chemicals use to enter through the body’s airways?
aev [14]

Through; Inhalation for most chemicals in the form of vapors, gases, mist etc.

4 0
3 years ago
Consider this C Program C++ Program Java Program or C# Program. It reads integers from the
LiRa [457]

Answer:

yeah

Explanation:

Consider this C Program or Java Program or Python Program. It reads integers from the standard input (until it gets a negative number) and puts them into an array. After that it calls processArray on the array, and then prints the contents of the array on standard output.

Currently, processArray does not modify the array. You have to change this program so that any sequence of two or more consecutive numbers even numbers in the array are removed from the array and replaced with just the first number of the sequence. In other words, in any sequence of even numbers, only the first number is retained and the others are removed. The processArrayfunction/method should modify the array in-place (preferably without creating a new array), and it should return the new length of the modified array

4 0
3 years ago
Select the best answer that completes the following sentences. Wireless technology changed the workday to
Minchanka [31]

Answer: around the clock availability

Explanation: i got 100

6 0
3 years ago
Read 2 more answers
Which of the following is a proper use of the application NetStumbler?Which of the following is a proper use of the application
Eddi Din [679]

Answer:

Finding rogue access points within your network

Explanation:

A

5 0
4 years ago
Read 2 more answers
Piers lives in an apartment and has an existing home television connection. He wants to subscribe to a high-speed internet conne
lina2011 [118]

Answer:

D. Wireless Network

Explanation:

A Wireless network has no need for cabling, trunking nor any heavy device installation. a Portable wireless device can solve his problem.

5 0
3 years ago
Other questions:
  • Ponce is the largest city on which coast of Puerto Rico
    13·1 answer
  • On an Android device, where can a user find the correct app to use to sync contacts and apps among devices?
    10·1 answer
  • A manager keeps a record of daily each transaction in input.txt. Each line contains three items: The invoice number, the cash am
    5·1 answer
  • HELP PLEASE ASAP!!! Does anyone know how to fix a broken iPhone which when I connect it to the charger it comes up with the Appl
    5·1 answer
  • Define a function calc_pyramid_volume with parameters base_length, base_width, and pyramid_height, that returns the volume of a
    7·1 answer
  • What is another word for: a location in memory that contains a value?
    7·2 answers
  • Many companies ban or restrict the use of flash drives
    11·1 answer
  • Which option identifies the type of engineers described in the following scenario?
    6·1 answer
  • Explain the role and importance of ict in daily life ?​
    7·1 answer
  • The Horse table has the following columns:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!