C realloc() [Closed]

Posts
2
Registration date
Tuesday August 15, 2017
Status
Member
Last seen
August 17, 2017
- - Latest reply: ac3mark
Posts
11990
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
April 23, 2019
- 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
11990
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
April 23, 2019
2486
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

Say "Thank you" 1

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

CCM 2415 users have said thank you to us this month

Posts
2
Registration date
Tuesday August 15, 2017
Status
Member
Last seen
August 17, 2017
0
Thank you
Thank u.. it was very helpful
ac3mark
Posts
11990
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
April 23, 2019
2486 -
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!
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
11990
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
April 23, 2019
2486 -
Great answer. I am glad you agree with me!