• Home
  • Tutorials
  • Interviews
  • Info Seed
  • Forums
  • Projects
  • Links
  • Contact Us
C Language
C POINTERS
MEMORY MANAGEMENT
INTRODUCTION
FIXED MEMORY
STACK MEMORY
HEAP MEMORY
Illustration with simple program
Functions to manage HEAP MEMORY
MEMORY ALLOCATION
MEMORY ALLOCATION-II
MEMORY ALLOCATION-III
MEMORY ALLOCATION-IV
Illustrations of MEMORY ALLOCATION
Illustration I
Illustration-I Contd..
Illustration-I Contd..
Illustration-I Contd..
Illustration II
Illustration-II Contd..
Illustration-II Contd..
Illustration III
Illustration IV
FRAME POINTER

 

 

NEXT ILLUSTRATION:

 Next address of the variable y is returned and which gets stored in x and the memory block of function abc() is de-allocated.

www.exploreroots.com

Next we try to store a value in the memory which has been de-allocated. As memory has been de-allocated and hence operating system may have allocated this memory to some other process. Due to this reason referencing to this address may cause an ERROR and hence we better should mark the option of uncertain or can’t say.

SOLUTION: The solution to the above problem can be that if we declare a pointer in place of simple variable and return the address stored in the pointer as:

Int* abc()

{

int* y= malloc(sizeof(int));

*y=3;

Return(y);

}

 

previous next
 
| Copyright © 2009 exploreroots- All Rights Reserved | Disclaimer |