First, here\'s my code:
#include
#include
#include
#include
#define NUM_SUITS 4
#define NUM_R
scanf("%d", &newcard);
and scanf("%d", &stay);
are a problem as the variables are bool
, but the format specifier is for int
. In 2 places, change like:
// scanf("%d", &newcard);
int t;
scanf("%d", &t);
newcard = !!t;
3 functions return int
but do not return anything. Change to void functions.
// int main_hand() {
void main_hand() {
There appears to be other logic issues too.
1) Code sometimes exists without knowing if won/loss
2) @Jongware comment above correct:
Lastly: If the same random sequence is still coming up, strip code to a bare main srand time printf rand
and see if that works. time()
, if not working always returns -1.
Or simple add the following and verify srand()
called with different values.
int main(void) {
unsigned now = (unsigned) time(NULL);
printf("now = %u\n", now);
srand(now);