delorie.com/archives/browse.cgi | search |
From: | Einstein <einstein DOT lam AT usa DOT net> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Writing a struct to disk |
Date: | Tue, 19 Aug 1997 19:59:21 +0800 |
Organization: | n/a |
Lines: | 26 |
Message-ID: | <33F98A99.7AEC324C@usa.net> |
References: | <33F93687 DOT 14CE173 AT psu DOT edu> |
NNTP-Posting-Host: | ip-52-115.dialup.hkstar.com |
Mime-Version: | 1.0 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
struct node { int number; unsigned char age; char *name; node *next; } If you want to save this struct, write this operator: ostream& operator <<( node src ); Assumptions: You are using C++. You can get the string length by some means. For instances, size_t strlen( const char *string ); Remarks: If the variable length string is allocated using the new operator, do not use the old char* and allocate the memory every time. Remember to save the string length. Einstein einstein DOT lam AT usa DOT net
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |