Ask Your Question
4

Why is the 2D dynamic array not increasing in size in C++?

asked 2023-06-14 06:35:15 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-06-14 07:04:01 +0000

ladyg gravatar image

There could be multiple reasons why a 2D dynamic array is not increasing in size in C++. Some common reasons include:

  1. Incorrect allocation: If the dynamic array is not allocated properly, it may not increase in size. It is important to use the correct C++ keyword (new or malloc) to allocate memory for the dynamic array.

  2. Memory leaks: If the dynamic array is not deleted properly, it may lead to memory leaks, which can prevent the array from increasing in size.

  3. Insufficient memory: If there is not enough memory available on the system, the dynamic array may not increase in size. It is important to check the available memory before trying to resize the array.

  4. Incorrect resizing logic: If the logic to increase the size of the array is incorrect or flawed, the dynamic array may not increase in size as expected.

  5. Incorrect indexing: If the indices used to access the array are incorrect, the dynamic array may not increase in size. It is important to use the correct indices to access the array elements.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-14 06:35:15 +0000

Seen: 17 times

Last updated: Jun 14 '23