c++

Hi,
I have a c++ programming assignment that is driving me crazy. Below is the assignment.

A simple sequential file-based database is required to help people keep track of contacts. The system should be able to hold information about the following at least.

-Surname
-First name
-Email
-Telephone no.
-Type (work/personnel)

You may add more information if you wish!

The file is always ordered in increasing alphabetical order on Surname.

The following operations are required (at least)
� add new entry
� modify an entry
� delete an entry
� search for entry or entries
� list all contacts to a file for printing (the output should look �neat�)

Design and implement a simple C++ system maintaining all relevant information on file.

Please help. Here is some code I have done but I am unable to get it to work.

// Code to Add an entry

#include <iostream>
#include <fstream> // stream class to both read and write from/to files
#include <string>

using namespace std; // no need for .h after libraries when using this line

int main()

{
ifstream instream_1; // temporary
ofstream outstream_1; // contacts
ifstream instream_2; // temporary
ofstream outstream_2; // contacts

// the following six lines will create the contacts and temporary text files
ifstream instream_1;  // declarations of streams instream_1 outstream_1
ofstream outstream_1;
instream_1.open\("temporary.txt", ios::in\);  // open the streams
outstream_1.open\("contacts.txt", ios::out\);
instream_1.close\(\);  // close the streams
outstream_1.close\(\); 

string surname_1, first_name_1, email_1, telephone_1, type_1; // string for old contacts
string surname_2, first_name_2, email_2, telephone_2, type_2; // string for new contacts

/*
outstream.open ("contacts.txt");
outstream.close();
*/

instream_1.open\("temporary.txt",ios::in\); // open for input operations
outstream_1.open\("contacts.txt",ios::out\); // open for output operations.

instream\_1&gt;&gt;surname\_1&gt;&gt;first\_name\_1&gt;&gt;email\_1&gt;&gt;telephone\_1&gt;&gt;type_1; 

cout&lt;&lt;"Enter Surname: ";
cin&gt;&gt;surname_1;
cout&lt;&lt;"\\nEnter First Name: ";
cin&gt;&gt;first\_name_1;
cout&lt;&lt;"\\nEnter Email Address: ";
cin&gt;&gt;email_1;
cout&lt;&lt;"\\nEnter Telephone Number: ";
cin&gt;&gt;telephone_1;
cout&lt;&lt;"\\nEnter Type\(Work / Personal\): ";
cin&gt;&gt;type_1;

capital Z as sentinel is used because of its ASCII value being more than all other letters
while \(surname_1 != "ZZZZZ"\) // 2 or more while loops are required
\{
instream\_1&gt;&gt;surname\_1&gt;&gt;first\_name\_1&gt;&gt;email\_1&gt;&gt;telephone\_1&gt;&gt;type_1;
outstream\_1&lt;&lt;surname\_1&lt;&lt;first\_name\_1&lt;&lt;email\_1&lt;&lt;telephone\_1&lt;&lt;type_1;
\}

while\(\(surname_2 &gt; surname_1\)\)
\{
instream\_1&gt;&gt;surname\_1&gt;&gt;first\_name\_1&gt;&gt;email\_1&gt;&gt;telephone\_1&gt;&gt;type_1;
outstream\_1&lt;&lt;surname\_1&lt;&lt;first\_name\_1&lt;&lt;email\_1&lt;&lt;telephone\_1&lt;&lt;type_1;
\}

instream_1.close(); // the file is closed
outstream_1.close(); // the file is closed

return 0;

}