#include<iostream>
#include<time.h>
#include<cstdlib>
#include<string>
usingnamespace std;
int main()
{
string name;
int SumOfCards;
int cards;
int player;
string choice="hit";
cout<<"Choose a name:";
getline(cin,name);
cout<<"\nHello "<<name<<",i wish to enjoy the BlackJack.\nGood luck"<<endl;
srand(time(NULL));
cards=rand()%4;
player=cards+cards;
cout<<player;
while(choice=="hit")
{
cin>>choice;
if(choice=="hit")
{
player=player+cards;
cout<<player;
}
elseif(choice=="stay")
{
cout<<player;
break;
}
}
}
I am trying to make a blackjack game but i have a problem with rand().
The problem is that the card dont change value so if it give to me 6(two cards so it is 3+3),after will give me 9 after 12 ,i mean it is only 3 always.
how can change it?