This is something I did as part of simple experimentation;
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int fun()
{
int d=10;
write(1,(int*)d,sizeof(d));
}
int main()
{
int x;
fun();
read(1,(int*)x,4);
printf("x=%d\n",x);
return 0;
}
As you can see I am trying to access value of d in fun() function via the IO stream (IO files) stdout; I tried using stdin as well but the thing is x value is not changing. (I tried in an online IDE.) But as per my thought stream, it should change to value of d.
Can anyone help me see why it is not doing that?