I made a method to fill a vector and another one to show it, when I execute the code it shows me the vector arriving only with values 0
This is the main
int main(int argc, char** argv){
int opc, tam = 5;
vector<int> vec(tam);
llenarVector(vec, tam);
cout << "Valores del vector\n" << endl;
imprimirVector(vec, tam);
system("pause");
return 0;
}
This is the method to fill the vector
void llenarVector(vector<int> vec, int tam)
{
int i;
srand(time(NULL));
for(i = 0; i< tam; i++)
{
vec[i] = i+1;
}
}
And this is to print the values
void imprimirVector(vector<int> vec, int tam)
{
int i;
for(int i=0; i< tam; i++)
cout << vec[i] << " ";
}
I'm doing something wrong, I still do not use the C ++ language and the use of vectors, thanks