righto then.
Cheers for all the comments I understand the junk variable thing alot better now.
Printable View
righto then.
Cheers for all the comments I understand the junk variable thing alot better now.
Actually, the area was probably initialized to nulls by the OS or the OS's loader. Then the stack was used by the c-program starter module which was linked into your (every) program by the compiler, which called main(). In this case, the data accessed is on the stack for the call to main(). It may very well stay the same until you change or upgrade your compiler or OS, or maybe even then. If not in main(), or even with args to main listed, the likelihood of repeatability is much much smaller. However if you got 2 for your prog, then this code probably gives 2, 6, largenumber, 0, 15, another large number. (gcc w/XP)
If this is so, you can probably use the whole alphabet and get pretty stable answers. The reason is that your OS is setting you up in a virtual partition cleared to nulls and your program starts at the same (virtual) address each time, with almost nothing but the loading and starting code running in it first.Code:#include<stdio.h>
main()
{
int a;
int b;
int c;
int d;
int e;
int f;
printf("a is %d \n",a);
printf("b is %d \n",b);
printf("c is %d \n",c);
printf("d is %d \n",d);
printf("e is %d \n",e);
printf("f is %d \n",f);
getch();
}
You can of course completely ignore people who have no idea what they're talking about and are just talking out their asses.
Quzah.
This dribble is coming from someone who does not indent their code, does not use 'int main(void)' and uses undefined and non standard functions.Quote:
Originally Posted by Karthur
:)
Oh sorry my mistake, so no values are given, its simply the last value in the memory section that is displayed. Now i also understand that better
\
Thanks
Quote:
Originally Posted by quzah
Karthur's post seemed substantially correct to me. Could you outline your issues with it (assuming quzah was referring to Karthur's post)?Quote:
Originally Posted by sand_man