Help with Address book program

I am working on an assignment for a C++ class and am having some difficulties. The assignment is to create an address book by writing to a text file. The operations it must perform are: searching the address book by a person's name, editing a person's information, adding a person to the phone book, and displaying all the information in the text file. I have been able to add people to the phone book successfully, but I am having issues after that. I am using strings to input the information into the text file but I don't know how to go about sorting it alphabetically or editing information. Would it be better to use arrays instead of strings? Here is the code I currently have, but it is only the for inputting information. Once the information is put in, it quits the program and sorts the names alphabetically (well it should). It does not need to be sorted immediately after new information is put in, only after the program has ended.

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  #include<iostream>
#include<fstream>
#include<string>
using namespace std;
void main()
{
	int choice;
	string first, last, phone, birth;
	cout << "Enter a number to choose an option:\n1. Find a person's information\n2. Add a person to the database\n3. Edit a person's information\n4. Display all records to the screen\n5. Quit\n";
	cin >> choice;
	if (choice==1)
	{
	}
	if (choice==2)
	{
		ofstream file("data.txt");
		if(file.is_open())
		{
			cout << "Enter a first name: ";
			cin >> first;
			file << first << "\n";
			cout << "Enter a last name: ";
			cin >> last;
			file << last << "\n";
			cout << "Enter a phone number: ";
			cin >> phone;
			file << phone << "\n";
			cout << "Enter a birth date: ";
			cin >> birth;
			file << birth << "\n\n";
		}
		file.close();
	}
	if (choice==3)
	{
	}
	if (choice==4)
	{
	}
	else return;
}
Topic archived. No new replies allowed.