void stack_main_access(void);
int main()
{
int loc_var=10;
clrscr();
stack_main_access();
printf("\nchanged value of loc_var %d \n",loc_var);
getch();
return 0;
}
void stack_main_access()
{
int num=0;
int *ptr=#
/*Searching the Exact Address of the Local Variable loc_var in Main() */
while(num!=5)
{
ptr++;
if(*ptr==10)
{
*ptr = 24;
printf("\nInside the IF %d \n",num);
num=5;
}
else
num++;
}
return;
}
The Program is compiled and checked using Turbo C compilers.
this step is quite complex we can acheive it simpler using the directory steps
ReplyDeleteyes, true ...it can be done in simple steps ..however to be in safer side , I did it like this....thanks for your inputs...
ReplyDelete