You seem to be assuming that an address in one program space will be the
same as the same address in a second program space.  That is not true.
Addresses are relative to the memory space allocated to each separate
program.  There is no way for one program to know anything at all about
memory used by a second program.

RobR



Robert D. Richardson
Product Engineer Software
 
RAD-CON, Inc.
TECHNOLOGY: Innovative & Proven
Phone : +1.440.871.5720 ... ext 123
Fax:  +1.440.871.2948
Website:  www.RAD-CON.com
E-mail:  rob.richard...@rad-con.com


-----Original Message-----
From: c-prog@yahoogroups.com [mailto:c-p...@yahoogroups.com] On Behalf
Of MAKHDUM HUSAIN NANDOLIYA
Sent: Thursday, August 05, 2010 11:53 AM
To: c-prog@yahoogroups.com
Subject: [c-prog] (unknown)






________________________________


I have run this programs.....

In first program, you are giving a value to variable 'a' is 100; now
suppose your address is -12.
then you will be stop the program one.
and you will execute program 2(file2.c)
so previous variable value will be deleted by compiler
automatically.....
so when you will run the program 2 you will not get the value of pa as
100.
It will be any garbage value.
and then you are also setting the value of pa to 10.
and if then you will not set the value of variable 'a' as 100 & you will
also don't get the value of 'a' as 10.
It will be also garbage value.



 
You have 2 files say file1.c and file2.c
>
>contents of file1.c are as follows :
>
>int main()
>{
>int a=100;
>
>printf(" %d", &a);
>
>getch(); //Halt the execution
>
>printf(" %d", a);
>
>}
>
>contents of file2.c are as follows :
>
>int main()
>{
>int *pa = (int*)(Here comes the address that was printed in file1.c);
>
>*pa = 10;
>
>}
>
>after halting the file1.c execution , file2.c is executed and then
file1.c is 
>resumed again to see the contents of a. What would be the output?
>
>
>
>  
>
>


Reply via email to