I am writing a c code for making parent and child process
int main
{
pid_t =pid;
pid=fork();
int a=21;
if(pid==0)
{
a=25;
printf("%d child \n",&a);
printf("%d child \n",a);
}
if(pid!=0)
{
printf("%d parent \n",&a);
printf("%d parent \n",a);
}
}
in my output address of variable a printed by both parent and child process are same. I have studied that when we fork a process each child process creates a copy of variables. if this is true then address must be different.
if this is false then when child process executes first then it will change the value at the location where a is stored. but my parent process is printing the value as 21 (according to its copy..)