Random Number

This is a discussion on Random Number within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Can someone plz email me the code on a random number. I know its something like srand(????? plz email me ...

  1. #1
    Unregistered
    Guest

    Red face Random Number

    Can someone plz email me the code on a random number. I know its something like srand(?????
    plz email me it at smokie_69@hotmail.com

    ttttthanks

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Before Quzah finds this I would do a search for say, off the top of my head, srand.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    how about random() with randomize()?
    Yoshi

  4. #4
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196

    Lightbulb random numbers

    well..do this

    #include <time.h>
    #include <stdlib.h>

    int main()
    {
    srand((usigned int)(time)(NULL)) // seeds it so get diff. num each time

    int x;
    x = rand() % 6 // this will make a random number 0-5, change the 6 to anythin you like

    return 0;
    }

  5. #5
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196

    re: random numbrs

    i spell something wrong on the last post

    #include <time.h>
    #include <stdlib.h>

    int main()
    {
    srand((unsigned int)(time)(NULL)); // seeds it so get diff. num each time

    int x;
    x = rand() % 6; // this will make a random number 0-5, change the 6 to anythin you like

    return 0;
    }
    nextus, the samurai warrior

  6. #6
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    And easier way to seed off of time is:

    srand(time(NULL));

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. rapid random number generation problem
    By Newton in forum C Programming
    Replies: 17
    Last Post: 09-19-2008, 03:08 PM
  2. Random number in range generation.
    By hebali in forum C Programming
    Replies: 19
    Last Post: 03-04-2008, 10:46 AM
  3. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 01:56 PM
  4. random number tutorial
    By 7stud in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2005, 03:41 PM
  5. Random Number Generator
    By Ikurik in forum C++ Programming
    Replies: 16
    Last Post: 08-17-2003, 08:34 PM

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