String array, help!

For some reason when I try to output the string array, it says that << does not match the operand

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
#include <ctime>
#include <array>
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	time_t p;
	time(&p);
	cout << ctime(&p) << endl;


	string Names[5] = { "Ronald Reagan", "Bill Clinton", "George Bush",
		"Barack Obama", "Jimmy Carter" };

	long int Salary[5] = { 25000, 300000, 185000,
		4500, 1300 };


	//Display table

	cout << "\t Names \t" << "\t Salary " << endl;
	for (int i = 0; i < 40; i++)
	{
		cout << char(220);
	}
	cout << endl;
	
	cout << setfill('.');
	cout << fixed << showpoint << setprecision(2);
	for (int i = 0; i < 5; i++)
	{
	
		
		
		cout << Names[i] << right << setw(10) << Salary[i] << endl;
	}


	system("PAUSE");
	return 0;
	
}
The << doesn't know what a string is because you didn't include the string header file eg #include <string>
Last edited on
Topic archived. No new replies allowed.