Vector

Im getting an error of an unqualified id in the for loop. I am trying to print the content of the entire vector but am unable to do so. Thank you for your help.

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
#include <iostream>
#include <vector>
#include <string>
using namespace std;



struct employee
{

      string Firstname;
      string Lastname;
      string ID;
      string Email;

};

int main()
{

   // int x;

    vector<employee> s(3);
    vector<employee>::iterator iter;

     cout << s.size() << endl;

     s.at(1).Firstname = "Jeff";
     s.at(1).Lastname = "Tom";
     s.at(1).ID = "4332";
     s.at(1).Email = "qwe@yahoo.com";

     for(int i=0; i<s.size(); i++)
                {
                s.[i];
    }
    }
To give you an idea, from line 33 to 36:

1
2
3
4
     for(int i=0; i<s.size(); i++)
                {
                s.[i];
    }


To:

1
2
3
4
5
	for (unsigned int i = 0; i < s.size(); i++)
	{
		cout << s.at(i).Firstname << "\t" << s.at(i).Lastname <<
		"\t" << s.at(i).ID << "\t" << s.at(i).Email << endl;
	}
Thank you so much! I was unaware that it needed each element following s.at.
Topic archived. No new replies allowed.