Answer the question
In order to leave comments, you need to log in
How to fill a vector in a separate function?
How to fill a vector through a function, such a problem that I don’t know what to write in return and the vector is simply not filled.
int ae(int n,vector <int> a) {
for (int i = 0; i < n; i++) {
cin >> a[i];
return 1;
}
}
Answer the question
In order to leave comments, you need to log in
Pass a pointer to a vector to the function.
Stop though, why do you need return in the loop? Remove and try without it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question