+ 1

Is it possible to change a element position from stack memory to heap memory if so, then how?

Just a curiosity to know if we can change position of memory or have some fun in memory management

16th Jan 2020, 3:56 PM
venkatrao bhnala
venkatrao bhnala - avatar
2 Answers
+ 2
venkat bhnala Generally any variable is first came in ram is stored in stack. To allocate in heap memory area you can use malloc() function. size_t bufsize = 1024; char *a; a = malloc(bufsize * sizeof(char)); Can be an good examples for managing memory.
16th Jan 2020, 4:04 PM
DishaAhuja
DishaAhuja - avatar
+ 1
Thanks is it possible to transfer elements stored in stack to heap coz mallac can only give u space in run time isn't it
16th Jan 2020, 4:07 PM
venkatrao bhnala
venkatrao bhnala - avatar