Greetings,
I have been working on ways to create massive amounts of random numbers from 0 to 7. I have been going nuts with rand(). I want to create a program that will print out sets of 8 random numbers (from 0 - 7) until I tell it to stop. Like well over a billion times. I have studied rand() and srand() and tried many things but the same pattern of 8 numbers keep coming up. Even when I quit the app and restart it, it still has the same pattern of same numbers. A simple example:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int x,y;
srand(time(NULL));
for(y=0;y<=100;y++);
{
for(x=0;x<=7;x++)
{
printf("%d ",rand()%8);
}
printf("\n");
}
}
Result:
1 6 7 4 5 2 3 0
7 4 5 2 3 0 1 6
5 2 3 0 1 6 7 4, etc
its the same pattern
even when I restart the app it is the same numbers with the same patterns
Im going nuts with this. I even entered random numbers for srand instead of time(NULL) and that did no good. I feel like I am missing something very simple. Can anyone point out what I am doing wrong? I have tried deleting the app and rebuilding. No good. I even rewrote my own rand() and srand() fucntions based on the ASNI C version. No good. Any advice?