Okay. We now have a very big topic, structs in the C language. Now we've already talked a little bit about what an abstract data type is, namely is a user-defined type. We've seen it with an enumerated type. So type is very critical to a problem solution, and we have native types: int, char, float and so on, including various pointer types, and these types can be used in a natural way to solve a lot of problems, especially text and mathematical problems. But what if you have a need to do something in game playing and you want to produce a datatype which you could think of as playing cards. So here's playing card. Not the best drawing of all, but that's just me, ace of spades. We want to have a way to represent that. Why? Well, we might have a strategy game in which you get to play poker against a bunch of other poker players and in such a strategy game, we want to be able to compute the likelihood of five card hands. So if you're drawing five cards only, that's what typically is a hand in poker. What is the likelihood that your five card hand is going to be a straight? Now a straight is something where you have five consecutive values in a row like a 7,8,9,10, jack. Jack is like an 11, queen is like a 12, king is like a 13. An ace can be either one, the low end of a straight or the high end. So if we were to compute that, we have to have a way to represent cards and then make that computation. I'm going to show you how to do this over the next few lectures. Typically, when somebody talks about a card, we're talking about its pips value and for our purposes, we're going to represent the pips value as 1-13, 13 being a king, 1 being an ace for the moment: ace 2,3,4, up to 13. Aces are going to end up special in many cases because aces can be used as both a low card and a high card, and that will add to the complication in some of our calculations. Then we have suit, and a suit can be clubs, diamonds, hearts, or spades. Now we're going to use this abstract datatype mechanism, the struct mechanism to build our own datatype for a card, and it's not the only way, it's not unique in a way to do it. I'm not even going to claim it's the best way. So struct card, it's going to have to components. Its going to have a pips component where it's going to be an int. Its going to be between 1-13, and a char component which is going to be a suit, and it's going to be one of these four characters which will be either a C for club, a D for diamond, an H for heart, or an S for a spade, and that's how we're going to at the moment represent it. As I said, it's not unique. Think about it, you can also redefine these things as enumerated types, and that might even be better because an enumerated type is a specific way to just have a few specific values that can be named. But for the moment, let's stick with this because its fairly easy to use. Look at the syntax of how a struct works. As a keyword struct, it's what we call the tag name. In the above, it was card, and then there's what's called a declarator list followed by a semicolon, and the declarator list were itself declarations, comma separated declarations. So we had a keyword and identifier, and remember when we write identifiers, we want to make sure they're literate, that contribute to the readability of the program. So when we say struct card, it becomes clear that we're using that as a abstract datatype for card. Now we can use that declaration. So we can say struct card, parenthesis; int, pips, char, suit and declare a deck to be an array of 52 cards. That would be a perfectly reasonable way to represent the ordinary poker deck. There's a further important thing that's very convenient, and that's a use of the keyword typedef to simplify declarations. So we can also say for example typedef struck, open brace and then we say float re, float in for real part and imaginary part, semicolon, close parenthesis, call it complex, semicolon, and now with this typedef, this specific struct did not have a tag name, but it has this identifier. That's basically the typedef the declaration that's going to be used, and now complex intrinsically represents the same thing as what before would have been struct complex. So instead of having to say struct complex all the time, we can now use a much simpler and intuitive abstract datatype name that we chose complex, and we can do the same thing by typedef in card.