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
Phoenix [80]
3 years ago
8

5. Write few lines of code that creates two arrays with malloc. Then write a statement that can create a memory leak. Discuss wh

y you think your code has a memory leak by drawing the status of the memory after you use malloc and the line of the code you claim that creates a memory leak.
Computers and Technology
1 answer:
Darina [25.2K]3 years ago
3 0

Answer:

 // function with memory leak  

void func_to_show_mem_leak()  {  

int *pointer;

pointer = malloc(10 * sizeof(int));

*(pointer+3) = 99;}  

 

// driver code  

int main()  

{  

    // Call the function  

   // to get the memory leak  

   func_to_show_mem_leak();  

     return 0;  }

Explanation:

Memory leakage occurs when programmers allocates memory by using new keyword and forgets to deallocate the memory by using delete() function or delete[] operator. One of the most memory leakage occurs by using wrong delete operator. The delete operator should be used to free a single allocated memory space, whereas the delete [] operator should be used to free an array of data values.

You might be interested in
What are all the physical components called?
Alecsey [184]

Physical Components to a computer are called hardware.

3 0
4 years ago
What might be some examples of Digital Citizenship Behavior?
likoan [24]

Answer:

Being nice to others and being respectful. Acting appropriately and with respect for you and others.

Explanation:

☆Hope this helps!☆

6 0
3 years ago
Pass the two arrays to a method that will display the integer value(s), if any, that appear in both arrays (note that the two ar
vampirchik [111]

Answer:

The solution code is written in Java

  1.    public static void checkCommonValues(int arr1[], int arr2[]){
  2.        if(arr1.length < arr2.length){
  3.            for(int i = 0; i < arr1.length; i++){
  4.                for(int j = 0; j < arr2.length; j++){
  5.                    if(arr1[i] == arr2[j]){
  6.                        System.out.print(arr1[i] + " ");
  7.                    }
  8.                }
  9.            }
  10.        }
  11.        else{
  12.            for(int i = 0; i < arr2.length; i++){
  13.                for(int j = 0; j < arr1.length; j++){
  14.                    if(arr2[i] == arr1[j]){
  15.                        System.out.print(arr2[i] + " ");
  16.                    }
  17.                }
  18.            }
  19.        }
  20.    }

Explanation:

The key idea of this method is to repeated get a value from the shorter array to check against the all the values from a longer array. If any comparison result in True, the program shall display the integer.

Based on this idea, an if-else condition is defined (Line 2). Outer loop will traverse through the shorter array (Line 3, 12) and the inner loop will traverse the longer array (Line 4, 13). Within the inner loop, there is another if condition to check if the current value is equal to any value in the longer array, if so, print the common value (Line 5-7, 14-16).

5 0
3 years ago
Beth’s multimedia business specializes in sound integration and editing. A New project requires video editing and the creation o
ANEK [815]

Answer:

A. Adobe illustrator

Explanation:

4 0
3 years ago
Does anyone play fortnite i want to be gifted vbucks please my epic is Springtrap_locks thx means a lot to me
Paladinen [302]

Answer:

This is not what this platform is supposed to be used for

Explanation:

Fortnite isnt a real game lol get a life

3 0
3 years ago
Other questions:
  • Write an interactive Python calculator program. The program should allow the user to type a mathematical expression, and then pr
    13·1 answer
  • Which is the common name for a program that has no useful purpose, but attempts to spread itself to other systems and often dama
    14·1 answer
  • Information is a valuable asset and not everyone in the world can be trusted with it. Therefore, we need to protect our valuable
    10·1 answer
  • What is the binary answer to the binary number 100 added to the binary number 11?
    14·2 answers
  • Assume the following JavaScript program was interpreted using staticscoping rules. What value of x is displayed in function sub1
    12·1 answer
  • Renee's creating a plan for her business's information system. What should she do after she determines the goals for her busines
    10·1 answer
  • Explain the components of Information System?​
    13·1 answer
  • In what way do networks help to protect data
    6·1 answer
  • 2. Discuss CORBA functions<br><br>​
    6·2 answers
  • What correlation is obtained when the pearson correlation is computed for data that have been converted to ranks?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!