G
Gregory W. Ernest
I am writing a c++ program for one of my classes. One of the assignments I
had was to create a program that would bascially calculate the number of
points in a game of Bridge using the principles of Object orientied
programming. The input is a stream of characters which represent the value
and suit of the card. For example, as would represent ace of spades, 2d
would be two of diamonds etc. To handle that I have created four arrays of
thirteen(since a suit can't have more than 13 values) characters , called
ClubArray, DiamondArray, HeartArray, and SpadesArray to store the different
values of a particulier suit. In the program I have to not only display the
points but also display the cards of a particulier hand by suit. To make
this more clear the output would look something like this:
Clubs: 10 6 2
Diamonds: A Q 10 3
Hearts: K J 7 5 3
Spades: A
Points = 16
To print out the values by rank I have used this while loop sequence:
cout<<"Clubs: ";
while(ClubArray != '\0'){
cin<<ClubArray<<" ";
i++;
}
cout<<endl;
All the values have been initialized to the NULL character('\0'), so the way
the loop works it would display any character that is not the null character
where it would break out of the loop since there are no values to be stored.
The problem that occurs though is that that line of code not only displays
the character that at ClubArray but all the characters that follow as if
it was a string!
I have tried several other output schemes like put(ch), cin.put<<etc,
putchar(ch) but to no avail. Can anyone help me?
I would really appreciate it.
had was to create a program that would bascially calculate the number of
points in a game of Bridge using the principles of Object orientied
programming. The input is a stream of characters which represent the value
and suit of the card. For example, as would represent ace of spades, 2d
would be two of diamonds etc. To handle that I have created four arrays of
thirteen(since a suit can't have more than 13 values) characters , called
ClubArray, DiamondArray, HeartArray, and SpadesArray to store the different
values of a particulier suit. In the program I have to not only display the
points but also display the cards of a particulier hand by suit. To make
this more clear the output would look something like this:
Clubs: 10 6 2
Diamonds: A Q 10 3
Hearts: K J 7 5 3
Spades: A
Points = 16
To print out the values by rank I have used this while loop sequence:
cout<<"Clubs: ";
while(ClubArray != '\0'){
cin<<ClubArray<<" ";
i++;
}
cout<<endl;
All the values have been initialized to the NULL character('\0'), so the way
the loop works it would display any character that is not the null character
where it would break out of the loop since there are no values to be stored.
The problem that occurs though is that that line of code not only displays
the character that at ClubArray but all the characters that follow as if
it was a string!
I have tried several other output schemes like put(ch), cin.put<<etc,
putchar(ch) but to no avail. Can anyone help me?
I would really appreciate it.