WDQ,

Your goals can easily be accomplished with a simple loop in main.

Please take a look at the simplified example provided below.

You will get some ideas from the sample.

Good luck.

Sincerely, Chris.

P.S. The simplified view function has not yet been fully implemented.

Code:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

static const string str_database_name("w:\\test\\data.txt");

static void view(void)
{
  ifstream is(str_database_name.data());

  if(is.is_open())
  {
    // TBD: Do something to show the lines...


    is.close();
  }

}

static void add(void)
{
  int    age;
  string name;

  cout << "Enter name: ";
  cin  >> name;

  cout << "Enter age: ";
  cin  >> age;

  ofstream os(str_database_name.data(), ios::out | ios::app);

  if(os.is_open())
  {
    os << name << ", " << age << endl;
    os.close();
  }
}

int main(int argc, string *argv[])
{
  ifstream is(str_database_name.data());

  if(!is.is_open())
  {
    ofstream os(str_database_name.data());

    if(os.is_open())
    {
      os.close();
    }
  }

  bool exit = false;

  while(!exit)
  {

    cout << "----------------------------" << endl;
    cout << "-- Data base program 1.1 ---" << endl;
    cout << "----------------------------" << endl;

    cout << endl;
    cout << "***********************************"<<"\n";
    cout << " 1) Add data "<<"\n";
    cout << " 2) view data"<<endl;
    cout << " 3) Exit"<<"\n";
    cout << "***********************************"<<"\n";

    char choice;
    cout << "Enter choice: ";
    cin  >> choice;

    switch (choice)
    {
      case '1':
        ::add();
        break;

      case '2':
        ::view();
        break; 

      case '3':
        cout << endl;
        cout << " Good bye and thanks for using" << endl;
        cout << " D.C.S database program" << endl;
        exit = true;
        break;

      default:
        cout << " Wrong choice";
        break;
    }
  }

  return 0;
}