randomizing order of execution of function

This is a discussion on randomizing order of execution of function within the C Programming forums, part of the General Programming Boards category; How would we randomize the order of execution of a set of functions. A random fuction with the starting variable ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    18

    randomizing order of execution of function

    How would we randomize the order of execution of a set of functions. A random fuction with the starting variable the time of day i.e. minutes.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > How would we randomize the order of execution of a set of
    > functions. A random fuction with the starting variable the time
    > of day i.e. minutes.

    Explain what you mean. Are you trying to generate a random number? Are you trying to execute a series of function calls who's order is random? What exactly. You need to give us more parameters for whatever it is you're trying to do.

    Code:
    #include <stdio.h>
    #include <time.h>
    
    void myfun1( void );
    void myfun2( void );
    void myfun3( void );
    void myfun4( void );
    void myfun5( void );
    
    int main ( void )
    {
       srand( time( 0 ) );
       switch( rand()%5 )
       {
          case 0: myfun1( ); break;
          case 1: myfun2( ); break;
          case 2: myfun3( ); break;
          case 3: myfun4( ); break;
          case 4: myfun5( ); break;
       }   
        return 0;
    }
    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    18
    We are trying to execute a series of function calls whose order is random and whose randomness changes at every program execution

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. calcualte the execution time of a function
    By George2 in forum C Programming
    Replies: 2
    Last Post: 06-15-2006, 01:27 AM
  3. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  4. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM
  5. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 10:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21