Well.. at least write the code for the class.
After you have a class, or linked list, write the function to read and write an object to the file. Thats done with.. file I/O, theres tutorials everywhere.
Code:
int g_accountKey = 0;
class BinaryFile
{
private:
int m_accountNumber;
double m_accountBalance;
int m_accountKey;
public:
BinaryFile() : m_accountNumber(0), m_accountBalance(0), m_accountKey(++g_accountKey) {}
BinaryFile(int p_accountNumber, double p_accountBalance) : m_accountNumber(p_accountNumber), m_accountBalance(p_accountBalance), m_accountKey(++g_accountKey) {}
int GetKey() { return m_accountKey; }
void Write() { //file I/O
}
};
void WriteAll()
{
//do the 100 allocated part here
}
If you wanted to do this efficiently you would probably make a linked list (and a key variable in it, not global), and have a key count the nodes, and a method to do the file I/O, but a function and a class would work.
You'll need to be reading and writting the right data, so you'll have to use a key or something to track them. If you were using C I/O you could figure out the position by sizeof(BinaryFile) * GetKey(); however in C++ you'd need to seek to position. Go to cplusplus for functions you can do with fstream.
The code posted is for me to guess, and for you to find out, something as basic as the above might not even compile
Oh and to do a random one you would simply make a blank BinaryFile object, and then out of your array of 100 BinaryFiles (using a vector) you use a rand to chooce one to assign. e.g. BinaryFile blankChoice = arrayBinaryFiles[rand % 100];. Or you could write a normal function that reads, but instead of using a key, uses a randomly generated number, etc.