TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Paul Wankadia
from: Frank Adam
date: 1996-10-26 12:38:08
subject: Writing structs

G'Day Paul,
 
-=> Quoting Paul Wankadia to All <=-
 PW> Hey, everyone -- how do I write a struct to a stream?  E.g. if I had
 PW> a 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
 PW> would I then write it to a stream?  Say, to the screen, to disk or to a
 PW> COM port? 
To a stream : 

stream = fopen("path\etc","wb");
 fwrite(&Packet,sizeof(struct Block1024),1,stream);

The screen you have to write it the old fashion way.
 printf("Packet No= %d",Packet.Packet_no);
 
Com ports, i'd get a com port library or steal it out of binkley. :-)
 
  L8r Frank (fadam{at}ozemail.com.au).
   
___ Blue Wave/DOS v2.21
 

---
* Origin: Melbourne PC User Group BBS (3:632/309)
SEEN-BY: 633/267 270
@PATH: 632/309 107 635/503 50/99 635/728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.