Help with saving and loading.

Hi all, I was wondering if any of you could help me with saving data, overwriting already saved data, and loading data. I was hoping to use this for a project I'm working on which allows a person to make a quiz and then save it in one of 2 files. One for editing, and the other for actually using the quiz. Any of you have any ideas on how I can do this? I'm using 10 arrays for questions and answers and all my code is working.
you can use ofstream for writing the data to files and ifstream for reading data from them. the data which u have in the arrays can be stored in the files, each element followed by a space, the you can read them back using ">>" operator.
thanks for the quick reply, but could you show me an example of wht I could do?
suppose i have an array of string and i want to write it to a file named test.txt and read from the same file then,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <fstream>
#include <iostream>
#include <string>
using namespace std;

int main()
{
   string a[2]={"hello","world"};
   ofstream os("test.txt");

   for(int i=0;i!=2;++i)
   {
       os<<(a[i]+" ");
   }
   os.close();
    ifstream is("test.txt");
    for(int i=0;i!=2&&!is.eof();++i)
    {
        is>>a[i];
        cout<<a[i];
    }
    is.close();
return 0;
}
Thanks mate.
Topic archived. No new replies allowed.