subject
Computers and Technology, 06.07.2021 15:20 lb31224

There is a memory management issue in the following main function. Please explain the memory management issues in this code and explain the reason behind this. int main()
{
char *p1 = malloc(20);
char *p2 = malloc(30);

strcpy(p1, "cat");
p2 = p1;

printf("%s", p1);

free(p1);
free(p2);

return 0;
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, simbupls
Technician a says that the radiator usually cools better if the front air dam is removed. technician b says that when a condenser has a leak it can be repaired easily with epoxy. who is correct?
Answers: 1
image
Computers and Technology, 22.06.2019 22:20, kaiyerecampbell95
Pp 4.1 design and implement a class called sphere that contains instance data that represents the sphere’s diameter. define the sphere constructor to accept and initialize the diameter and include getter and setter methods for the diameter. include methods that calculate and return the volume and surface area of the sphere (see pp 3.5 for the formulas). include a tostring method that returns a one-line description of the sphere. create a driver class called multisphere, whose main method instantiates and updates several sphere objects.
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, opgbadwolf5
What provides an array of buttons for quick access to commonly used commands and tools
Answers: 1
image
Computers and Technology, 24.06.2019 15:00, mbede002
Who introduced the concept of combining artificial and natural light in the studio
Answers: 1
You know the right answer?
There is a memory management issue in the following main function. Please explain the memory managem...

Questions in other subjects:

Konu
Mathematics, 13.04.2020 15:38