Hidden Lynx
Hidden Lynx

Reputation: 69

Why can't use realloc function to resize the stack which is of dynamic array?

The book tells me that I should declare a new, larger array (malloc) and copy the data from the old array to the new array to resize the stack.

But why can't I use realloc to adjust the size of the stack's length?

Upvotes: 0

Views: 101

Answers (1)

Mohit Jain
Mohit Jain

Reputation: 30489

Nobody stops you from using realloc. Moreover realloc is preferable. Without looking at context of material, I can not tell the intention of author why does he want to use malloc.

Upvotes: 1

Related Questions