• 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

Q- What is the output of the following code?

Int main()

{

Int*x;

x= abc();

printf(“%d”,*x);

return 0;

}

 

Int* abc()

{

Int y=3;

Return (&y);

}

  1. 3              (b) 5       (c) Can’t say

Ans: Many would answer it as 3 but it is wrong. The way we have tried to do it is wrong. As we enter into main we have a memory allocated for variable x and then function abc is called.

www.exploreroots.com

 

 

 

Now as function abc() is called, a new frame is added in the stack. We save the return address to main in the stack. Then a variable y is declared.

www.exploreroots.com

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