Hi,

I have a structure whose one member is a pointer to another structure .

Code:
struct first{
int i;
}fir;

struct second{
char name[10];
struct first * point;
}sec;
I have assigned the following values to structure member

Code:
 sec.point= (struct first*)malloc(sizeof(struct first)); 
  printf("Enter name\n");
  scanf("%s",sec.name);
  printf("Enter number\n");
  scanf("%d",&sec.point->i);
I want to pass second structure to a another process using message queues.

Code:
msgid= msgget((key_t) 10,IPC_CREAT|0666);

if(msgid<0)
  {
   perror("Msg Queue not created");
   exit(1);
  }

if(msgsnd(msgid,&sec,sizeof(struct second),0)<0)      
  {
   perror("Message not sent");
   exit(1);
  }
I then receive the message in another process
Code:
struct first{
int i;
}fir;

struct second{
char name[10];
struct first * point;
}var;

main()
{

 int msgid;
  var.point= (struct first*)malloc(sizeof(struct first)); 
 
 
  msgid=msgget((key_t)10 ,IPC_CREAT|0666);	/*Creating Message Queue*/

 if(msgid<0)
  {
   perror("Msg Queue not created");
   exit(1);
  }


 if(msgrcv(msgid,&var,sizeof(struct second),0,0|MSG_NOERROR)<0)
 {
  perror("Message not recieved");
  exit(1);
 }
 printf("name was\n");
 printf("%s",var.name);
 printf("nuber was\n");
 printf("%d",var.point->i);
 
 
 }
It displays the character value but shows "segmentation fault" for the interger value...Any idea if a pointer of one process can work in another...I could have used a normal variable for the first structure but i have some specifications to follow which has defined structure like these. However if i copy individual members into a character array (using memcpy) and pass the array in queue it do works.... If pointer is passed through an array why not struture..