pass vector to function?

Does anyone know how to make that work?

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
#include <iostream>
#include <vector>
using namespace std;
int isPrime (int a, vector c)
{
    for (int b = 0; b < c.size(); b++)
    {
       if (a % c[b] == 0) return 0;
    }

    return a;
}
int main()
{
   vector <int>v;
   for (int i = 2; i < 100; i++)
    if (isPrime(i, v) == i)
        {
        cout << i << endl;
        v.push_back(i);

        }
        cout << v.size();
    return 0;
}
line 4: change vector c to const vector<int>& c
Thanks. What does adding the const do? Because the program runs, and it runs faster without it.
Topic archived. No new replies allowed.