Where are the program variables stored in memory(text, data or stack segments)
- From: kr <rahul.kashyap98@xxxxxxxxx>
- Date: Tue, 20 Nov 2007 06:47:46 -0800 (PST)
Hi All,
Suppose I consider a sample program as given below:-
#include<stdio.h>
#include<stdlib.h>
int i;
int main()
{
char *test(int i);
char *tmp = NULL;
i = 10;
tmp = test(i);
printf("%s\n", test(i));
free(tmp);
return 0;
}
char *test(int i)
{
char *str = (char*)malloc(20);
sprintf(str, "i value is: %d", i);
return str;
}
This program contains several variables (global, local and dynamically
allocated variables).
How to figure out which variable is stored in which segment viz. text,
data, stack or heap? Is there any tool to get an idea about it?
Thanks and Regards,
kr.
.
- Follow-Ups:
- Re: Where are the program variables stored in memory(text, data or stack segments)
- From: Malcolm McLean
- Re: Where are the program variables stored in memory(text, data or stack segments)
- From: Eric Sosman
- Re: Where are the program variables stored in memory(text, data or stack segments)
- From: santosh
- Re: Where are the program variables stored in memory(text, data or stack segments)
- From: Mark Bluemel
- Re: Where are the program variables stored in memory(text, data or stack segments)
- From: Johannes Bauer
- Re: Where are the program variables stored in memory(text, data or stack segments)
- Prev by Date: Re: Why (-10) * abs(i-1) == 10 in Linux??
- Next by Date: Re: isodigit
- Previous by thread: HI I AM VIVEK
- Next by thread: Re: Where are the program variables stored in memory(text, data or stack segments)
- Index(es):
Relevant Pages
|