Random Seed without Time function

This is a discussion on Random Seed without Time function within the C Programming forums, part of the General Programming Boards category; Hello, Does anyone know of a relatively simple algorithm for generating a random seed without using the time function? I'm ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    2

    Random Seed without Time function

    Hello,

    Does anyone know of a relatively simple algorithm for generating a random seed without using the time function?

    I'm interfacing C with assembly code, and the m68k-coff-gcc cross-compiler on Solaris is not recognizing the time() function, even though I included <time.h> and the -lc flag. It doesn't have any trouble recognizing rand() or srand(). It just begins to fail when time() is called.

    This is my only option for compiling, so if anyone has any ideas for a simple function that sets a random seed without calling time(), that would be appreciated!

    This is only for a game, so I don't need anything fancy.

    Thanks!

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    You could use getpid() instead.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    2
    Aha! It worked!

    Thank you soo much!

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1) Prompt user for a number.
    2) Seed srand with it.
    3) Profit!

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    ---
    Join Date
    May 2004
    Posts
    1,379
    Quote Originally Posted by quzah
    1) Prompt user for a number.
    2) Seed srand with it.
    3) Profit!

    Quzah.
    It's almost idiot proof. But an idiot would enter the same number everytime

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM
  4. inputting time in separate compilation
    By sameintheend01 in forum C++ Programming
    Replies: 6
    Last Post: 03-13-2003, 03:33 AM
  5. Need Help with Random Function in C
    By sujr21 in forum C Programming
    Replies: 2
    Last Post: 12-05-2001, 03:00 PM

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