Error

I need a little help. I'm trying to input some info from a file I this is the first time using structures. I made an array to hold my info. I keep getting an error I was just trying to have a loop in main so I could see if the program was getting what I wanted I keep getting an error <<
1>c:\users\jordan\documents\visual studio 2010\projects\whatshesent\whatshesent\whatshesent.cpp(62): error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'infoType' (or there is no acceptable conversion)
I need help resolving this.


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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;

const int SIZE = 10;

//structure
struct infoType
{	
	string fname;
	string lname;
	string address;
	string phone;
};


// Function to get info from file.
void readData(ifstream &fin, infoType tele[], int& size)
{
	
	for( int i = 0; i < 1; i++)
	{
		fin >> tele[i].fname;
	}





}



void displayMenu()
{
	cout << "Phone Directory Program " << endl;
	cout << endl;
	cout << "Options" << endl;
	cout << "[A]dd and entry to the phone directory. " << endl;
	cout << "[D]elete an entry from the phone directory. " << endl;
	cout << "[U]pdate an entry from the phone directory. " << endl;
	cout << "[L]ist the entire phone directory. " << endl;
	cout << "[E]xit the menu" << endl;
}



int main()
{
	ifstream fin("input.txt");
	
   int newSize = 0;
   infoType tele[SIZE];
	

	 readData(fin, tele, newSize );

	 for(int i = 0; i < 1; i++)
	 {
		 cout << tele[i] << endl;

	 }
  
  displayMenu();
 
  system("pause");
 
 return 0;

}


Thanks.
cout << tele[i] << endl;
¿what do you expect that to do?
@ ne555 (3898)

void readData(ifstream &fin, infoType tele[], int& size)

void readData(ifstream &fin, infoType *tele, int& size)

Which is faster?
First one?
Your compiler error is telling you exactly what's wrong. On line 62, you have:

cout << tele[i] << endl;

However, tele[i] is of type infoType, and you haven't defined the << operator for that type.
Last edited on
Topic archived. No new replies allowed.