Ok . I am writing a game that generate random 6 array numbers from 1 to 10 the program MUST be using by srand(time(NULL or 0)); Now, I want, because it's a little bit of difficult to generate series per second something that the program will generating the numbers auto..


at 17:00:00 --> Array_S01[6] = {0,1,2,3,4,5};
at 17:00:01 --> Array_S02[6] = {5,4,3,2,1,0};
at 17:00:02 -->Array_S03[6] = {2,4,6,8,9,1};
at 17:00:59 -->Array_S59[6] = {1,3,6,9,0,4};

so for that purpose I need a for loop that I have already create.. but it's always take correct only the 1 second..

if I try to get the random numbers of 17:00:05 automatically (to set the time correctly and hit the button at 17:00:05 I am taking different numbers that the 5th second of my loop DOES!!!! )

below a simple code::

int t;
   t = time(0);

   for (int t=0; t<60; t++){
for(i=0; i<6; i++)

// i don't want to share the rest of my code it's for personal used sorry.. It's working 
// anyway... I just looking forward to fixed the program with the loop of variable T; 


Thank you in advance!!

with the following take the first 2 seconds correctly:::

   long t;
   t = time(NULL);
  long now = clock();
for(clock(); clock() < 1; clock - now ){
    for(i=0; i<6; i++)
    //do something


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.