I NEED HELP WITH THIS FUNCTION PLEASE

This is a function in the program I'm working with:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void hacerReserva(int **av, int fil, int col) 
{ 

	int f,c, dni; 
	cout << "Dar Fila y Asiento:?"; 
	cin >> f >> c; 
	if (av[f-1][c-1] !=0){
		cout<<"Asiento ocupado, seleccione otro por favor"<<endl;
	}
	else{ 
		
		cout << "Dar DNI(sin letra)"; 
		cin >> dni; 
		av[f-1][c-1] = dni;
	}
}


when this is true-->if (av[f-1][c-1] !=0)I want the program to go back to the top to start the function again. This is a program that contains a menu and with the program the way it is right now when this condition is true it just goes back to the menu and asks the user to select an option. However I dont want this, because I dont want to get out of this function until the condition its not true so that everything that is at the end of the function happens. How can I do this the easiest way?? HELP PLEASE, THANK YOU!!!
Last edited on
You need to edit your post and repaste your code in code tags so that it is readable: http://www.cplusplus.com/forum/articles/16853/
Thanks for adding the code tags. :-)
Do you mean something like this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void hacerReserva(int **av, int fil, int col) 
{
    int f,c, dni;

    do {
        cout << "Dar Fila y Asiento:?"; 
        cin >> f >> c; 
        if (av[f-1][c-1] != 0)
            cout << "Asiento ocupado, seleccione otro por favor\n";
    } while (av[f-1][c-1] != 0);

    cout << "Dar DNI(sin letra)"; 
    cin >> dni; 
    av[f-1][c-1] = dni;
}

Last edited on
Great!! Thank you very much
Topic archived. No new replies allowed.