Need help with cin

I have this function :

my_class card_input ( )
{
int n ;
string c ;
char cstr[15] ;
my_class card ;

cout << "\n Type a card : " ;
cin.getline( cstr, 15 ) ;
numar = atoi( strtok ( cstr, " " ) );
culoare = strtok ( NULL, " " );

card.set_number ( n ) ;
carte.set_color ( c ) ;

return card ;
}

Now, when I call this function in another function

void verify_card ( )
{
bool n = 1;
my_class card = card_input( );

while ( n )
{
if ( some_other_object == card )
{
do some stuff...

return ;
}
else
{
card_input( ) ;
}
}
return ;
}

if for the first time my input do not verrify the equality in the if statement, when i'm asked again, even if my other input verrify the condition i'm still asked for my input.

Make n = 0; when you got
some_other_object == card ;.
Topic archived. No new replies allowed.