C realloc() [Closed]

Posts
2
Registration date
Tuesday August 15, 2017
Last seen
August 17, 2017
- - Latest reply: ac3mark
Posts
10909
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
December 7, 2018
- Nov 30, 2017 at 05:17 PM
Hi..

Iam refreshing c language using this useful resource http://c-language.com/

iam not able to understand the concept of realloc()..help me
See more 

3 replies

Best answer
Posts
10909
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
December 7, 2018
1
Thank you
From what I briefly read, it allocates used memory. SO lets say you have an array, and you want to expand the array, in basic you would REDIM the array, with a new value, as in:

DIM A(1) REM variable A now has 1 storage space in its array.
....some code manipulates variable A and it needs more space......
REDIM A(5)
Now variable A can hold 5 values! Remember when trying to access arrays, the count starts a 0, not 1!

I believe that is what realloc(ate) does. Let me know if anyone comes to the same conclusion.

It's kind of fun to do the impossible! -Walter Elias Disney

Thank you, ac3mark 1

A few words of thanks would be greatly appreciated. Add comment

CCM has helped 2558 users this month

Posts
2
Registration date
Tuesday August 15, 2017
Last seen
August 17, 2017
0
Thank you
Thank u.. it was very helpful
ac3mark
Posts
10909
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
December 7, 2018
-
I will leave it up to you, if you are satisfied, to mark as solved! thank you for the feedback, and not just using the knowledge and leaving us without feedback!
Posts
13
Registration date
Friday November 3, 2017
Last seen
February 23, 2018
0
Thank you
relloc() is an dynamic memory allocating function that is used in c language. This relloc() dynamically reallocates the memory block.
ac3mark
Posts
10909
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
December 7, 2018
-
Great answer. I am glad you agree with me!