Hi all
how do load vars with random values ?
for example I need 3 random integers from 1 to 10 1 in each in each var .
What is the C code for declaring 3 integer variables loaded with a random integer for 1 to 10 each ?
Thanks Elico
As I said I need to declare 3 variable like var1, var2, var3 each will be assinged with a random int from 1 to 10 ,
What is not clear ?
Elico
Look up the C library functions srand, rand.
What kind of 'random' do you need?
- 'True' random numbers (like readings of a Geiger counter)? - Pseudorandom? The latter can be cryptographically secure or not. - Fixed 'random' numbers (like the one in my first post)?
All of the above are random numbers. But they are very different. Which one do you need? That's what is not clear.
It does not matter as long I can get an integer from 1 to 10 assign it in a var and use it to make decisions in the C code.
So what is the C code for declaring 3 vars amd assigning the random integers into them ?
what header files I need to use ?
thanks Elico
... and use it to make decisions in the C code
And it's OK if those decisions will be the same for each program run? If so, save yourself the trouble and use the numbers 7, 2 and 8. Because using header files like stdlib.h and functions like srand(), rand() won't be any better. Seriously.
It would be a bad day if the guy who wrote that response had anything to do with the boeing software.
Or just run a hardware timer, and use % 10. Whatever.
Those random numbers imitate "real" values that come in from the A2D ports . So they have to have random nature .
Is the guy who wrote this for real? Does he earn money from writing code?
Detail matters there. What happens if the timer is running at 100Hz and he makes 3 calls within 10ms to get the numbers only to find they're all the same.
Look pal, if you expect people to post ENTIRE SPECIFICATIONS for software you are at the wrong place. My posts are and were meant to stimulate ideas, not to offer a water tight solution. Grow up ! I had it.
Sorry chum. All they did with me was stimulate disbelief.