Arrays help

i need help to Write a program that is able to save a list of items such as books, CDs, or DVDs and the items that are saved must have attributes associated with them. For example a book has a title, author, publisher, and ISBN.
I would like to create a program that is able to save the database of items to a file on the hard drive and also retrieve it from the hard drive.
Any help would be appreciated. Thanks!
I have this for a start of how to set up a storing program.

#include <iostream>
#include <iomanip>
using namespace std;

int main ()
{
const int arraySize = 10;
int a[arraySize] = { 2, 6, 4, 10, 12, 89, 68, 45, 37 };
int i, hold;

cout << "Data items in original orger\n";

for (i = 0; i < arraySize; i++){
cout << setw(4) << a[i];
}

for (int pass = 0; pass < arraySize - 1; pass++){
for (i = 0; i < arraySize - 1; i++){
if (a[i] > a[i + 1])
hold = a[i];
a[ i ] = a [ i + 1];
a [ i + 1] = hold;
}
}

cout << "\nData items in ascending order \n";

for (i = 0; i < arraySize; i++)
cout << setw(4) << a[i];
cout << endl;

return 0;
}
Last edited on
I think most people faced with your objective would use a structure (struct) or class to create objects to hold the desired attributes. They could be stored in a linked list or vector or even an array. Are you familiar with usage of files in C/C++?
- Ideally, i would use an array of classes here unless you want to attempt to keep multiple parallel arrays(or vectors).
Topic archived. No new replies allowed.