Still stuck

Hi ,
I'm still stuck. I don't know why this is so hard.It's a phone directory program. OptionD function is the issue which is a function that will have the user enter the phone number. The program finds the phone number and corresponding information. I used a structure and an array for this the array is the same type as my structure. The function is successful in finding the information now trying to move things from one array to another except the thing I want to get rid of is such an issue. Someone said if you use std::vector. Now the question is can I uses that with a structure? If I use it in the same way I use my array now. Also if I'm going to do some sort of swap and leave the information I don't want in the original array how big do I make the other array? Please any help, please.
Sorry I'm so CONFUSED RIGHT NOW!!!
This is what I got

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
42
43
44
45
46
47
48
49
50
//Option D function 
void optionD( ifstream &fin, infoType tele[], int& size)
{	
	
	int oldSize = 0;
	int index = 0;
	string dPhone;
	bool found = false;
	
	

	cout << tele[5].phone;
	cout << "You have selected option D " << endl;
	cout << "Please enter the phone number of the record to be deleted." << endl;

	cin >> dPhone;
	
	while( index < size && !found )
	{
		if(tele[index].phone.compare(dPhone)== 0)
		{
		cout << "The entry to be deleted is " << endl;
		cout << tele[index].lname << endl;
		cout << tele[index].fname << endl;
		cout << tele[index].streetAdd << endl;
		cout << tele[index].cityStateZ << endl;
		cout << tele[index].phone << endl;
		found = true;
		}
		
		index++;
	}
		
	cout << size;
	//Deleting the element from Array
	for ( int i = 0; i < 5; i++ )
	{
		cout << tele[i].lname << endl;
		cout << tele[i].fname << endl;
		cout << tele[i].streetAdd << endl;
		cout << tele[i].cityStateZ << endl;
		cout << tele[i].phone << endl;


	}
	
	
	
	
}



1
2
3
4
5
6
7
8
9
//structure
struct infoType
{	
	string fname;
	string lname;
	string streetAdd;
	string cityStateZ;
	string phone;
};



array
1
2
infoType tele[SIZE];
		


calling the function // int new size =10
optionD(fin,tele,newSize);
Put an else on line 30 -- you don't want to increase index after you've found the index you want. I've already given you a couple ways to remove the element from the array in your other thread...

Link for convenience: http://www.cplusplus.com/forum/general/85585/

Why does this function take an ifstream& as a parameter?
Last edited on
Topic archived. No new replies allowed.