wte.c: add prototype for random selection
This commit is contained in:
parent
94ad845dab
commit
49fe655474
1 changed files with 16 additions and 4 deletions
20
src/wte.c
20
src/wte.c
|
@ -2,10 +2,22 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "wte.h"
|
#include "wte.h"
|
||||||
|
|
||||||
|
static size_t get_entry_count()
|
||||||
|
{
|
||||||
|
size_t count = 0;
|
||||||
|
count++;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
static int get_proposition()
|
static int make_suggestion()
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
srandom(time(NULL)); // seed random with current time
|
||||||
|
size_t count = get_entry_count();
|
||||||
|
if (count) {
|
||||||
|
size_t choice = random() % count;
|
||||||
|
printf("choice: %lu", choice);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,10 +40,10 @@ int main(const int argc, const char **argv)
|
||||||
}
|
}
|
||||||
goto exit_main;
|
goto exit_main;
|
||||||
}
|
}
|
||||||
if (!get_proposition()) {
|
|
||||||
error("%s", "error");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (make_suggestion()) {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
exit_main:
|
exit_main:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue