J
john
I have recently started using C++ Builder and am trying to convert some
16 bit BC 4.52 code. My problem is using 16 bit integers that have been
stored as part of a structure in a file. When I read the entire structure
in with Builder using an 'fread' function, Builder assumes that the
integers are 32 bit integers and all of the data in the structure from
this
point is offset. This is true even if the data type is declared as 'short'
or '__int16'.
struct TEST
{
char a;
short int b;
long c;
} Test;
If this structure is written to disk using BC 4.52, it has a size of 7
bytes. When Builder attempts to read it in, it assumes a size of 9 bytes.
I've tried typing the short int in many different ways, but using the
Inspect window of Builder shows that b always has a size of 4 bytes. If
the
structure I need to read in were actually this simple, I'd get over it by
writing some code to position everything, but the structure I have
contains
over 100 elements and it would be nice if it could be read directly. Is
this a problem with all 32 bit development platforms? Thanks for any help.
16 bit BC 4.52 code. My problem is using 16 bit integers that have been
stored as part of a structure in a file. When I read the entire structure
in with Builder using an 'fread' function, Builder assumes that the
integers are 32 bit integers and all of the data in the structure from
this
point is offset. This is true even if the data type is declared as 'short'
or '__int16'.
struct TEST
{
char a;
short int b;
long c;
} Test;
If this structure is written to disk using BC 4.52, it has a size of 7
bytes. When Builder attempts to read it in, it assumes a size of 9 bytes.
I've tried typing the short int in many different ways, but using the
Inspect window of Builder shows that b always has a size of 4 bytes. If
the
structure I need to read in were actually this simple, I'd get over it by
writing some code to position everything, but the structure I have
contains
over 100 elements and it would be nice if it could be read directly. Is
this a problem with all 32 bit development platforms? Thanks for any help.