Stop cin with "-1" in an array

First of all, my english is not the best, but I think you'll understand me.

While I'm loading an array, i need to stop that loading with the value "-1", but I don't know where to put the if that I need. Here is my example, obviously it's not correct.

ARRAY is my ARRAY that I'm loading. It has 10 slots.
CONT is a counter to know from where I have to fill with "0" my array.
CONT = 0

cout << " Enter a value for: ["<<i<<"]" << endl;
cin >> ARRAY[i];
CONT++;
if (ARRAY[i] == -1){
for (int i = CONT; i < 10; i++){
ARRAY[i] = 0;
}
}
cout << "CONT = "<<CONT<<endl;


Thanks!
here is your solution use break.
for(int i = 0;i<10;i++)
    {
        cout << " Enter a value for: ["<<i<<"]" << endl;
        cin >> ARRAY[i];
        CONT++;
        if (ARRAY[i] == -1)
        {
            for (int j = CONT; j < 10; j++)
            {
                    ARRAY[j] = 0;
            }
            break;
        }
    }
    cout << "your count is = "<<CONT <<endl;

Thanks for the reply, I solved using a temporary int before i assign it to the Array, so that way I can verify if it was equal to -1.


Thanks
Topic archived. No new replies allowed.