Dice
Rolling dice.
Loading...
Searching...
No Matches
dice.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef unsigned int uint_t
 
typedef uint_tdices_t
 

Functions

uint_t roll_dice (void)
 
dices_t roll_dices (uint_t numRolls)
 
void init_dice (void)
 

Typedef Documentation

◆ dices_t

typedef uint_t* dices_t

Definition at line 7 of file dice.h.

◆ uint_t

typedef unsigned int uint_t

Definition at line 3 of file dice.h.

Function Documentation

◆ init_dice()

void init_dice(void)

Definition at line 21 of file dice.c.

21{ srand((uint_t)time(NULL)); }
unsigned int uint_t
Definition dice.h:3

Referenced by main().

Here is the caller graph for this function:

◆ roll_dice()

uint_t roll_dice(void)

Definition at line 11 of file dice.c.

11{ return ((uint_t)rand() % 6) + minDiceVar; }
@ minDiceVar
Definition dice.c:7

References minDiceVar.

Referenced by roll_dices().

Here is the caller graph for this function:

◆ roll_dices()

dices_t roll_dices(uint_tnumRolls)

Definition at line 13 of file dice.c.

13 {
14 dices_t dices = malloc(numRolls * sizeof(uint_t));
15 for (uint_t roll = 0; roll < numRolls; roll++) {
16 dices[roll] = roll_dice();
17 }
18 return dices;
19}
uint_t roll_dice(void)
Definition dice.c:11
uint_t * dices_t
Definition dice.h:7

References roll_dice().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function: