i have to write a program which read from the keyboard a line of numbers and save them into an array, numbers have to be written just in a line, i wrote this but doesn`t work because of an infinite loop, any suggestion?
int main() {
    int numCasos = 0, contNumCasos = 0, numElem = 0;
    string aux;
    cout << "Number of cases: " << endl;
    cin >> numCasos;
    while (contNumCasos < numCasos) {
        cout << "Number of elements: " << endl;
        cin >> numElem;
        cout << "Enter the Elements separated by space: " << endl;
        cin.ignore();
        vector.cont = 0;
        int i = 0;
        while ((vector.cont < numElem) && getline(cin,aux,' ')){
            vector.v[i] = stoi(aux);
            vector.cont++;
            i++;
        }
    }
    cout << sumaBuenos(vector) << endl;
    cin.ignore();
    system("pause");
    return 0;
}
An example: 
console: Number of elements: 
user: 4 
console: Enter the Elements separated by space: 
user: 2 43 65 56 
--this has to be the vector 
-- vector.v[0] = 2 
-- vector.v[1] = 43
-- vector.v[2] = 65 
-- vector.v[3] = 56 
 
     
     
     
    