Expected Unqualified-id

Hey guys! I'm new here and new to C++. I'm trying to do this exercise:
 
Read a set of integers into a vector. Print the sum of each pair of adjacent elements. 

And this is my attempt:
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
#include <iostream>
#include <vector>
#include <string>
using std::string;
using std::cout; using std::cin; using std::endl;
using std::vector;

int main()
{
    int number;
    vector<int> v1;
    
    while ( cin >> number )
    {
        v1.push_back(number);
    }

    
    for ( vector<int>::size_type i = 0; i < v1.size() ; ++i )
    {
        if ( (i+1) <= (v1.size() - 1) )
            cout << (v1.[i] + v1.[i+1]) << " ";
    }
    
    
    
    
    return 0;
}


However, I'm getting a "Expected Unqualified-id" error at the
cout << (v1.[i] + v1.[i+1]) << " "; line.

Any help would be much appreciated !
Last edited on
Remove points. Instead of

cout << (v1.[i] + v1.[i+1]) << " ";

there shpuld be

cout << (v1[i] + v1[i+1]) << " ";
Oh wow did'nt realise that. Thanks! Problem solved.
Topic archived. No new replies allowed.