Question

In: Computer Science

When it comes to dynamic memory allocation and delete[] pointer, what does it mean to say...

When it comes to dynamic memory allocation and delete[] pointer, what does it mean to say that, CRT detected that the application wrote to memory after end of heap buffer?

I tried to duplicate the error by deleting the pointer address twice and it didn't produce the same error code so that's not it. What might cause this problem?

Solutions

Expert Solution

char* str = malloc(3);
OK, str now points to 3 chars on the heap.

Suppose you write 4 chars into that str:

buffer[0] = 'a';
buffer[1] = 'b';
buffer[2] = 'c';
buffer[3] = 'd';

now you have access the memory which is not allocated for you, now program will behave abnormally


Related Solutions

Purpose Review and reinforcement of pointers, dynamic memory allocation, pointer arithmetic, passing pointers to a function,...
Purpose Review and reinforcement of pointers, dynamic memory allocation, pointer arithmetic, passing pointers to a function, returning a pointer by a function, dangling pointer, and memory deallocation, pointer initialization, and struct data type. Project description In this project, you will create a database of employees of an organization while meeting the requirements described below. Your program MUST NOT interact with the user to receive inputs, so that the instructor and/or the teaching assistant can save a big time in testing...
Q. What does it mean when we say a data structure is dynamic?
Q. What does it mean when we say a data structure is dynamic?Its size in memory is fixed.It contains functions for operating on the data it contains.Its behavior changes in response to its environment.It is capable of expanding and contracting as data is added and removed.Q. If we had a class named MapData, how would we declare its destructor?delete[] MapData();destructor* MapDataDestructor();NULL_PTR this->MapData();~MapData();Q. When traversing a singly-linked list with a dummy header node, where do we begin the traversal pointer?At element...
In the following keypad notation Use a class and dynamic allocation of a pointer variable to...
In the following keypad notation Use a class and dynamic allocation of a pointer variable to enter the digit code of the following text input MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY Use an inherited class using pointer variable to output the phone number from the following text input 1-800-COMCAST 1-800-VERIZON 1-800-BANCORP 1-800-MYKOHLS 1-800-JCPENNY Write C++ code and pseudocode in a doc file A computer key board has defect (like speech defect in humans) in reading for ‘p’ /’P’ as...
In the following keypad notation Use a class and dynamic allocation of a pointer variable to...
In the following keypad notation Use a class and dynamic allocation of a pointer variable to enter the digit code of the following text input MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY Use an inherited class using pointer variable to output the phone number from the following text input 1-800-COMCAST 1-800-VERIZON 1-800-BANCORP 1-800-MYKOHLS 1-800-JCPENNY Write C++ code and pseudocode in a doc file A computer key board has defect (like speech defect in humans) in reading for ‘p’ /’P’ as...
What does it mean when people say, “plan for retirement”?
Answer the following in 25 words or moreWhat does it mean when people say, “plan for retirement”?How should you “plan for retirement”?How does what you learned about stocks, bonds, and mutual funds benefit retirement plans?Where does your income come from in retirement? How do you calculate this income for planning purposes?What if you don’t plan for retirement?
What does Piaget mean when he says development comes before development? What does Vygotsky mean when...
What does Piaget mean when he says development comes before development? What does Vygotsky mean when he says learning comes before development?
Describe what psychologists mean when they say that attention and working memory have a limited capacity....
Describe what psychologists mean when they say that attention and working memory have a limited capacity. Discuss at least two implications of this limited capacity for learning in the classroom.
What does it mean to say a membrane channel is selective? What doesit mean when...
What does it mean to say a membrane channel is selective? What does it mean when we say a membrane channel is gated? Describe two different types of membrane gated channels and explain why we do not always want them open.  
What does "derivability of relation" mean when it comes to relational databases?
What does "derivability of relation" mean when it comes to relational databases?
What does it mean when we say an interface is 'Up-Up'?
What does it mean when we say an interface is 'Up-Up'?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT