function not finishing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
void classify_parts(string& next_char, ifstream& in_stream,
                              string card_value[], string card_suit[],
                              string& bet,string& player1_hand )
//seperates hand into components. i.e. bet, card value and suit.
{    
     int i=0;//is a count to increase the index of the arrays
     while(!in_stream.eof())
     {      
              
          in_stream>>next_char;
          while(is_card_value(next_char))
          {
              card_value[i]+=next_char;
              
          }
          while (is_card_suit(next_char))
          {
              card_suit[i]=(next_char);
             
              
          }
          i++;
          cout<<i<<endl;
          while (is_bet(next_char,bet))
          {
              bet+=next_char;
              cout<<bet<<endl;
              
          }  
     }
     for(i=0;i<NUMBER_OF_CARDS_IN_A_HAND;i++)
     {
          
          player1_hand+= (card_suit[i]);
          player1_hand+= (card_value[i]);
          player1_hand+= (SPACE);
     }
     player1_hand+= (DOLLAR_SIGN);
     player1_hand+= (bet);
     cout<<player1_hand;
}


it doesn't seem to be putting any values into the player1_hand string

this is the is card suit function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
bool is_card_suit(string next_char)
{
    /*if(next_char==HEARTS||next_char==SPADES||next_char==DIAMONDS||
        next_char==CLUBS)
        return(true);
     else
        return(false);*/
        
     for(int i=0; i<NUMBER_OF_SUITS; i++)
         {
             if(next_char==SUITS[i]);
                {
                     return(true);
                }
         }
         return(false);
}
this is the is card value function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
bool is_card_value(string next_char)
//checks if a character is possibly a card value and returns true if it is
//returns false otherwise
{
    /* if(next_char=='a'||next_char=='A'||next_char=='j'||next_char=='J'
        ||next_char=='k'||next_char=='K'||next_char=='Q'||next_char=='q'
        ||isdigit(next_char))
        return (true);
     else 
        return (false);*/
        
     for(int i=0;i<NUMBER_OF_CARD_VALUES;i++)
           {
                if((CARD_VALUES[i]) == next_char)
                ;
                  {
                       return(true);
                  }
                
           }       
        return(false);
        
}
Line 15 in is_card_value looks wrong
the is bet functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
bool is_bet(string next_char, string& bet)
//checks if next char is a possible bet and if so adds that character to bet
{
     for(int i=0;i<10;i++)
     {
         if(next_char==INTERGERS[i])
         {
              return(true);
         }
         return(false);    
     }
     
}
          
 
Last edited on
yea i changed that but i'm still haveing the same problem
i also have it cout messages after each of the function and the only one i get is the one that follows is card suit and i get it an infinite number of times
Topic archived. No new replies allowed.