Bill Cunningham said:
I have no idea what to do with time () or another function to change the
time_t data type to int to get numbers say from 0-20 that are ints.
What for? If you want numbers in the range 0-20, what does that have
to do with time()?
time()
reports a huge number of seconds and when using rand() truely produce a fake
randomness.
I don't know what you mean by that. You're using time() and rand()
together somehow? How exactly? Presumably srand() is involved
somehow, but you didn't mention it.
I want smaller numbers. We have functions like strtod and strtol
to change chars into doubles or longs why not change time_t to int?
time_t is an arithmetic type capable of representing times. That's
*all* the standard tells you about it. You can convert a time_t value
to int the same way you'd convert any numeric type to another one
(just assign it), but that's not a useful thing to do; for one thing,
the result of time() may or may not fit within the range of int.
Let's back off a bit. You're trying to accomplish something, but you
haven't actually told us exactly what it is. Instead, you've thrown
together a few things that you might *use* to accomplish something
(time(), type time_t, type int, numbers in the range 0-20, rand(),
"smaller numbers") -- things that apparently aren't doing what you
want them to do.
It's like asking "Should I use a hammer or a screwdriver? What about
a staple gun?" without saying what you're trying to build.
First, tell us *exactly* what you want to accomplish. State your
problem without referring to any possible solution or piece of a
solution.
Then, *separately*, you might ask whether some proposed solution, or
something like it, will do what you want. If you can express the
proposed solution in C code, even if it doesn't work or is incorrect,
that's great. But we can't help without knowing what you're trying to
do.
Have you read <
http://www.catb.org/~esr/faqs/smart-questions.html>?
You might also take a look at section 13 in the comp.lang.c FAQ,
particularly the questions on random numbers.