Hi, I'm working on a blackjack program and of course I need a random card draw function. Now the problem is I don't have one, it's I need to improve it
Code:
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <string>
using namespace std;
int a;
int draw(int a);
int main(){
draw(c);
cin.ignore();
};
int draw(int a) {
int b, c, e;
string d;
srand(time(0));
b = rand() % 52;
c = b % 4;
e = b % 12;
switch (c){
case 0:
d = "Hearts";
case 1:
d = "Diamonds";
case 2:
d = "Spades";
case 3:
d = "Clubs";
}
cout<< e << " of "<< d;
return b;
};
The out put always has clubs as the suit. Any suggestions on how to improve the randomness?