D
Drake
Well, I'm stuck in legacy land and I need a helping hand.
We're trying to give some modern value-added functionality to
a circa-1985 fortran proggie.
The program produces a binary file, by itself no problem...
each record needs to be converted into std::vector<mystruct>
I'm having a helluva time with the binary-->(pod)datatype conversion.
Although I've referred to C++ containers, iostreams
are not used... FILE* only. Insert/extract operators are not an option.
Here's 3 records (broken into lines for easy reading)...
D5840000428F0000140501000B0000000000
993A000066C70000140501000F0000000000
C0880000538D0100140501001D0000000000
Here's (pod) mystruct...
static struct IDX_RECORD /* length 18 bytes */
{
unsigned long respnum; // 4 bytes
unsigned long datfile_offset; // 4 bytes
unsigned char disposition; // 1 byte
unsigned char status; // 1 byte
unsigned char segment_svd; // 1 byte
unsigned char not_used; // 1 byte
unsigned short segment_dupr; // 2 bytes
unsigned long next_segment_offset; // 4 bytes
};
Is this one of those times fscanf IS the "better" (whatever that means) way?
Assuming the powers have big-time aversion to "scan" functions,
what's an alternative?
Thank you for your thoughts,
Drake
We're trying to give some modern value-added functionality to
a circa-1985 fortran proggie.
The program produces a binary file, by itself no problem...
each record needs to be converted into std::vector<mystruct>
I'm having a helluva time with the binary-->(pod)datatype conversion.
Although I've referred to C++ containers, iostreams
are not used... FILE* only. Insert/extract operators are not an option.
Here's 3 records (broken into lines for easy reading)...
D5840000428F0000140501000B0000000000
993A000066C70000140501000F0000000000
C0880000538D0100140501001D0000000000
Here's (pod) mystruct...
static struct IDX_RECORD /* length 18 bytes */
{
unsigned long respnum; // 4 bytes
unsigned long datfile_offset; // 4 bytes
unsigned char disposition; // 1 byte
unsigned char status; // 1 byte
unsigned char segment_svd; // 1 byte
unsigned char not_used; // 1 byte
unsigned short segment_dupr; // 2 bytes
unsigned long next_segment_offset; // 4 bytes
};
Is this one of those times fscanf IS the "better" (whatever that means) way?
Assuming the powers have big-time aversion to "scan" functions,
what's an alternative?
Thank you for your thoughts,
Drake