Help with card game please?

I am trying to make a card game in console, and all I am trying to do now is just display 5 random numbers, which are the cards. I have the numbers set from 1 to 10, I will put in the face cards and card classes(spades, hearts, etc.) later, that is why I have all the #define s at the top.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <stdio.h>
#define faceCard_Jack "J"
#define faceCard_Queen "Q"
#define faceCard_Kind "K"
#define faceCard_Ace "A"
using namespace std;

int main(char card[4])
{
    //Generates random seed
    srand(time(NULL));

    card[0] = rand() & 10 + 1;
    card[1] = rand() & 10 + 1;
    card[2] = rand() & 10 + 1;
    card[3] = rand() & 10 + 1;
    card[4] = rand() & 10 + 1;

    cout<<card[0]<<", "<<card[1]<<", "<<card[2]<<", "<<card[3]<<", "<<card[4]<<endl;
}


So whats wrong with it? It just crashes when I try to run it. That, and any suggestions on it?
Main() should only take zero or two arguments. The code given compiles on my compiler but it gives warnings, guessing other compilers might not even compile. Also the expression rand() & 10 + 1 doesn't make sense (& is used as bitwise AND), guessing you mean rand() % 10 + 1

Also typo, faceCard_Kind should be faceCard_King.

You could also use an enumeration to define the face cards if you wanted, that way the card array could be defined in terms of ints rather than chars and you wouldn't need the #define statements.

Also the current #define statements probably should be like faceCard_Jack 'J' since 'J' is a character but "J" is a string.
Alright thanks. I did mean % btw, I get them mixed up all the time.
Topic archived. No new replies allowed.