Thread: C++ random function

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    1

    Unhappy C++ random function

    i'll be happy if some one tell me how to use random function in C++.i'm using bloodshed as dev-c++.this is my instant of using rand() function but it does not work.help me!!
    srand(time(0));
    magic_number=(rand() %3)+1;

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    45
    What's the error message?

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    What do you mean by "not working"?

    "Not compiling"?
    "Not giving the proper output"?
    "Crashing"?

    Have you included the proper headers?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Replies: 5
    Last Post: 02-08-2003, 07:42 PM