writing structs and classes to disk
Posted
by Phenom
on Stack Overflow
See other posts from Stack Overflow
or by Phenom
Published on 2010-05-22T18:08:12Z
Indexed on
2010/05/22
18:10 UTC
Read the original article
Hit count: 163
The following function writes a struct to a file.
int btwrite(short rrn, BTPAGE *page_ptr)
{
long addr;
addr = (long) rrn * (long) PAGESIZE + HEADERSIZE;
lseek(btfd, addr, 0);
return (write(btfd, page_ptr, PAGESIZE));
}
The following is the struct.
typedef struct {
short keycount; /* number of keys in page */
int key[MAXKEYS]; /* the actual keys */
int value[MAXKEYS]; /* the actual values */
short child[MAXKEYS+1]; /* ptrs to rrns of descendants */
} BTPAGE;
What would happen if I changed the struct to a class, would it still work the same?
If I added class functions, would the size it takes up on disk increase?
© Stack Overflow or respective owner