N
Neel
Hi,
I made a simple struct and 'm trying to assign value to its members
but nothing is being actually assigned (I tested it by printing it...)
code :
struct header{
unsigned char msgtype;
unsigned char uoid[20];
unsigned char ttl;
unsigned char reserved;
unsigned int datalength;
};
struct header h;
h.msgtype=((unsigned char)0xFA);
cout<<"size "<< sizeof h<<endl; //prints "28"
unsigned char buf[20];
memset(h.uoid, 0, 20);
memcpy(h.uoid,(unsigned char *)GetUOID((char *)node_instance_id,
"hello", buf, sizeof buf),20); //GetUOID is func
h.ttl=1; //prints nothing
cout<<"TTL "<<h.ttl<<endl;
h.reserved=0;
h.datalength=strlen(myhostname)+sizeof (myport);
any idea what's wrong???
I made a simple struct and 'm trying to assign value to its members
but nothing is being actually assigned (I tested it by printing it...)
code :
struct header{
unsigned char msgtype;
unsigned char uoid[20];
unsigned char ttl;
unsigned char reserved;
unsigned int datalength;
};
struct header h;
h.msgtype=((unsigned char)0xFA);
cout<<"size "<< sizeof h<<endl; //prints "28"
unsigned char buf[20];
memset(h.uoid, 0, 20);
memcpy(h.uoid,(unsigned char *)GetUOID((char *)node_instance_id,
"hello", buf, sizeof buf),20); //GetUOID is func
h.ttl=1; //prints nothing
cout<<"TTL "<<h.ttl<<endl;
h.reserved=0;
h.datalength=strlen(myhostname)+sizeof (myport);
any idea what's wrong???