jhon
10-04-2004, 04:59 PM
Hi,
I wonder how to cast a char* to a struct.
I know the folowing way:
char *buffer;
struct X *x;
x = (X *)buffer;
but let's assume the following definition:
struct X
{
char a[100];
int n;
so, a will read all data until '\0' and then stop and no data will be read to variable n.
how can I fix it?
I wonder how to cast a char* to a struct.
I know the folowing way:
char *buffer;
struct X *x;
x = (X *)buffer;
but let's assume the following definition:
struct X
{
char a[100];
int n;
so, a will read all data until '\0' and then stop and no data will be read to variable n.
how can I fix it?