filling array with a user input exit

Hi, I do not know how to exit my array with a user input value.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  void fillArray(double newThrust[Capacity][Cols], int& numOfElements){

	double thrust;
	
	cout << "\nEnter thrust curve data (0 for thrust to end list)" << endl;
	

		for(int i = 0; i < Capacity; i++){

			for(int j = 0; j < Cols; j++){
				cin >> thrust;
				newThrust[i][j] = thrust;
				}
			}

			numOfElements++;
		

}


this is my function so far and do not know how to exit it using a "0". Please help.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 void fillArray(double newThrust[Capacity][Cols], int& numOfElements) {

    double thrust;
	
    cout << "\nEnter thrust curve data (0 for thrust to end list)" << endl;
	

    for(int i = 0; i < Capacity; i++){

        for(int j = 0; j < Cols; j++){

            cin >> thrust;
                                
            if( std::abs(thrust) < 1.0e-6 ) goto done ; // break out of nested loop

            newThrust[i][j] = thrust;
            ++numOfElements ;
        }
    }

            // numOfElements++;
		
    done:
}

Thank you very much. Can you please explain that if statement cause i have not seen that yet in my class.
Floating point numbers are inexact representations of real numbers. Though a comparison with zero ( == 0.0 ) would usually work as expected, as a general programming technique, one should avoid exact comparisons of floating point numbers.
http://www.parashift.com/c++-faq/floating-point-arith.html
i have a new request. with the exit being 0 i also need to input that zero into that last array column. right now its a crazy number.
nevermind i figured out a way i can do it without that number being zero.
Topic archived. No new replies allowed.