R
Roman Mashak
Hello, All!
I met this code recently on some open source sites. What may be the point of
using such construction:
typedef struct cmd
{
unsigned int cmdack;
unsigned int code;
unsigned int data[1];
} CMD;
....
int proc_cmd()
{
char msg[]={"CMD"};
int lenth = strlen(msg);
CMD *t, *r;
int st[100];
int sr[100];
t = (CMD *)st;
r = (CMD *)sr;
...
/* process msg */
if(strncmp((char *)&r->cmdack, msg, len) == 0
{
....
}
}
Why to define structure's member as 'unsigned int' and then implicitly do
type casting?
With best regards, Roman Mashak. E-mail: (e-mail address removed)
I met this code recently on some open source sites. What may be the point of
using such construction:
typedef struct cmd
{
unsigned int cmdack;
unsigned int code;
unsigned int data[1];
} CMD;
....
int proc_cmd()
{
char msg[]={"CMD"};
int lenth = strlen(msg);
CMD *t, *r;
int st[100];
int sr[100];
t = (CMD *)st;
r = (CMD *)sr;
...
/* process msg */
if(strncmp((char *)&r->cmdack, msg, len) == 0
{
....
}
}
Why to define structure's member as 'unsigned int' and then implicitly do
type casting?
With best regards, Roman Mashak. E-mail: (e-mail address removed)