Question: I'm trying to make simple function to adding elements to my array but it doesnt work well. can you help me?

```

void insert(int &n, string name[]){
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>name[i];
    }
}

int main(){
    int n;
    string name[n];
    insert(n,name);
}

```

Answer: 
C++ arrays [] do not grow on run time, use std::vector instead.

Also, since you are reading an integer from cin, you should insert in the vector the same type, not a string.

```
std::vector<int> v;   // creates a vector 
v.push_back( 10 );    // include a number in a vector  

```

<https://godbolt.org/z/v4xG6WEo1>
You may want to write this...

```
#include <string>
#include <vector>
#include <iostream>
using namespace std;

void insert(int& n, vector<string>& names) {
    cin >> n;
    names.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> names[i];
    }
}

int main() {
    int n;
    vector<string> names;
    insert(n, names);
    for (const auto& s : names) {
        cout << s << endl;
    }
}

```