if statement with arrays help

This is a discussion on if statement with arrays help within the C++ Programming forums, part of the General Programming Boards category; hello
Im making a card game using arrays to setup the deck and produce cards. i've got everything done except ...

if statement with arrays help

hello

Im making a card game using arrays to setup the deck and produce cards. i've got everything done except for scoring both the players hand and dealers hand, to see who wins. I dont know how I would setup an if statement for seeing what you have in a hand once all cards are flipped.
this is what I have so far for dealing the cards and scoring the hand:

Well if you think about it, it's clear there is a fair bit of logical statement checking to do, so you are going to be left with a lot of messy code if you try and handle it within each of those if statements.
You will need to create further functions that take the current hand and go off and do some counting.

I would use an enum for convenience and have your checking functions return a value appropriate to the players hand value.

Code:

enum hand_values {
ROYAL,
FHOUSE,
//etc
//etc
};

You are probably going to require, or should use, more than one function to accomplish this in a well structured way. Also don't forget to always record any loose high card values anyway (if the player does not have a hand that scores all of the cards), in case of ties...

An undeclared identifier error occurs when the compiler can not recognise an identifier within your code; be it a sequence of characters representing: an object or variable name, class name etc. In your case we are looking at the error with regards to two variable names that have stumped the compiler.

If you have a look at your void function "checkroyal", there are no declarations for the variables with character sequences "face" and "suit". Instead, the closest thing that we can find, are the parameters residing with the function, named "wface" and "wsuit".

Therefore, I think you have just made a simple typo when trying to use the variables passed to the function. Try renaming the actual parameter variables to "face" and "suit" (also changing them in the function declaration for consistency), or renaming each of the references to "face" and "suit" to "wface" and "wsuit".

In future, try to learn the meanings of some common errors, such as this one. In the long run it will save you a lot of time, instead of having to wait for forum replies

before you go any further with this i suggest you save yourself some pain and learn how to write your own 'struct' data type to represent the cards. each card has a suit and a value at least, as well as other potential attributes like 'is_dealt' , is_face, point_val, etc depending on your game and how you want to do things. So I would personally stop now and go back and rewrite, then when you come to calculate your hands you should find it easier as all the information required for each card is located within it's datatype and the function calls will be simpler also.