Hello. So I set to write a simple Blackjack program, and what I have done so far (not the whole code) works fine except that the rand() function keeps giving out the same values over and over. So it's not really random, and I don't know what I'm doing wrong. Will you take a look at it?
Code:
#include<stdio.h>
int main(void){
int n,i,k,cont;
char card;
for(n=0;n<20;n++){
cont=0;
printf("#####################################\n");
printf(" BLACKJACK\n\n");
do{
printf("Nova carta?\n");
scanf("%c",&card);
if(card == 's'){
cont+=rand()%12;
if(cont>21){
printf("%d",cont);
printf("Temos pena mas perdeu!!\n");}
if(cont==21){
printf("BLACKJACK!!!");}
else{
printf("%d\n",cont);}
}
}while(card!='n' && cont < 22);
system("pause");
system("cls");
}
return 0;
}