I have a program where I use records of the form:
// declaring a struct for each record
struct record
{
int number; // number of record
vector<int> content; // content of record
};
Within main I then declare each record:
record batch_1; // stores integers from 1 - 64
record batch_2; // stores integers from 65 - 128
Where each batch stores 64 integers from a list of numbers (in this instance from a list of 128 total numbers). I would like to make this program open ended, such that the program is capable of handling any list size (with the constraint of it being a multiple of 64). Therefore, if the list size was 256 I would need four records (batch_1 - batch_4). I am not sure how I can create N-many records, but I am looking for something like this (which is clearly not the solution):
//creating the batch records
for (int i = 1; i <= (list_size / 64); i++)
{
record batch_[i]; // each batch stores 64 integers
}
How can this be done, and will the scope of something declared within the for loop extend beyond the loop itself? I imagine an array would satisfy the scope requirement, but I am not sure how to implement it.
vector<record> batch(list_size / 64)and then init it as needed in a loop? You're already usingvectors.vectorin the definition of your record. How would you define its function?