-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoker.c
50 lines (45 loc) · 782 Bytes
/
poker.c
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
42
43
44
45
46
47
48
49
50
/*Poker? I barely know her!*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "poker.h"
Card randCard() {
Card c = (Card) malloc(sizeof(Card));
c->rank = (rand() % 13 + 1);
int r = rand() % 4;
switch (r) {
case 0:
c->suit = CLUBS;
break;
case 1:
c->suit = HEARTS;
break;
case 2:
c->suit = SPADES;
break;
case 3:
c->suit = DIAMONDS;
break;
default:
c->suit = CLUBS;
}
return c;
}
void printCard(Card c) {
char *s;
if (c->suit == DIAMONDS) {
s = "Diamonds";
} else if (c->suit == CLUBS) {
s = "Clubs";
} else if (c->suit == HEARTS) {
s = "Hearts";
} else if (c->suit == SPADES) {
s = "Spades";
}
printf(" (%d,%s) ",c->rank,s);
fflush(stdout);
}
void burnCard(Card c) {
free(c);
}