when we reallocate memory to pointer then it will not receive the address of other position it will allocate space next to the previous address…..if there is data at next position then if we write it will overwrite previous data..
when we reallocate memory to pointer then it will not receive the address of other position it will allocate space next to the previous address…..if there is data at next position then if we write it will overwrite previous data..
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
No because when there is no further contigous free memory it will give you an error and -1 return value.Every process has its own context so other process cannot take memory of other processes without its permission………
when u ask for more memory from a same location using realloc, it returns the same memory location if the asked no of memory blocks are available..else it will move the previous data from the same location to he new address where the blocks are available and returns the new address
thus realoc should be used as
ptr = (char *)realloc(ptr,10*sizeof(char));