Are you getting compiler errors? If so can you please post them so people can help?
I pretty much agree with LB except for his last point. You also did not free allocated memory (try
delete
).
If you want to re-read the written structure, then insert this
myFile.seekg(0, std::ios::beg);
before you read the structure.
1 2 3 4 5 6 7 8
|
struct b_tree_node {
int num_keys; // number of keys in this node
int key_val[3]; // key values (0 to num_keys - 1)
int child[4]; // child file addresses (0 to num_keys)
// [record index, not byte address]
// may need filler to force zeros in any padding of the struct
} ;
|
You should not be hard-coding supposedly dynamic data like that.
I highly recommend you read this article:
http://www.cplusplus.com/articles/DzywvCM9/
_________________________________
Joshua Schweigert wrote: |
---|
I just love it when programmers like yourself think that just because you know more than the next guy that you can act like an asshole towards them. |
I can see where this is coming from, it isn't uncommon for programmers to act cocky, however LB was not trying to act that way.
Do not respond with rudeness when someone is trying to give you helpful criticism. He's trying to help you get rid of bad habits that can bite you later.