PW> Hey, everyone -- how do I write a struct to a stream? E.g. if I had a
PW> struct like this :
PW> typedef struct Block1024 {
PW> unsigned char Packet_no;
PW> unsigned char Data[1024];
PW> unsigned long CRC;
PW> };
PW> and then went
PW> Block1024 Packet;
PW> (to create a struct called Packet, of typedef struct Block1024), how would
PW> I then write it to a stream?
PW> Say, to the screen,
What did you hope that "CRC" would look like when printed to the screen?
PW> to disk
fwrite(&Packet, 1, sizeof Packet, file_ptr);
I can never remember which way around the "1" and "sizeof
Packet" goes though, although either will work in this case, you
should really put what you're really trying to do which is write 1 lot of
1029 bytes, not 1029 lots of 1 byte.
PW> or to a COM port?
You "need" comms routines to do that. Various unsavoury people
would attempt to write to stdaux or open file "COM3", but
invariably they will fail. FREQ "PDCOMM" from 3:711/934. While
it lasts. BFN. Paul.
@EOT:
---
* Origin: X (3:711/934.9)
|