Whoops, did too much C++ programming these days, in C this should really be: #include <stdlib.h> #include <time.h> int main (int argc, char *argv[]) { unsigned int r; srandomdev(); /* use this on non-BSD systems: srandom(time (0)); */ r = random () % 99999 +1; printf ("%d\n", r); return r; }