push_back

Hi,

When I try to compile the code below I get this error: error: expected ';' before 'push_back' at line 17 but am unsure where I am missing it as I have tried placing it in various places but it just changes the error message.

The question just provides from vector<char> to cout <<myName[i] and we are supposed to predict the output that is why I have written the code below but I might have missed something while doing this.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 #include <iostream>
#include <vector>
using namespace std;

int main()
{
    vector<char> myName;
    myName.push_back('E');
    myName.push_back('l');
    myName.push_back('i');
    myName.push_back('z');
    myName.push_back('e');
    for(int i = 1; i < 5; i+=2)
    {
        myName[i] = '(';
    }
    myName push_back(')');
    for (int i = 0; i < myName.size(); i++)
    {
        cout << myName[i];
    }
    return 0;
}


If anyone can see what is missing your help would be appreciated.

Thanks
Line 17, you forgot the '.'
Second set of eyes always helps. Thanks firedraco, appreciate your quick response here.
Topic archived. No new replies allowed.