question about output
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
|
void read_player1_hand(ifstream& in_stream, string card_value[], string card_suit[],string& bet, string player1_hand)
{
int i=0;
card_value[NUMBER_OF_CARDS_IN_A_HAND];
card_suit[NUMBER_OF_CARDS_IN_A_HAND];
string next_char;
string player1_hand;
while(!in_stream.eof())
{
in_stream.get(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++;
while (is_bet(next_char)
{
bet+=next_char;
}
}
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)
}
|
If if want to out put
player1_hand
straight to an ofstream would
1 2
|
ofstream out_stream;
out_stream<< player1_hand
|
work or would the insertion operator skip the white space or will it skip the whitespace?
i meant or will it output the whitespace because it's part of the string
player1_hand is just a
std::string, and those work just fine with
std::ostreams:
1 2
|
std::string MyString ("This is a string.");
std::cout << "The string reads: " << MyString << std::endl;
|
Because
std::ofstream is derived from
std::ostream, it should work as expected.
Last edited on
okay thanks
Topic archived. No new replies allowed.