C++ random function

This is a discussion on C++ random function within the C++ Programming forums, part of the General Programming Boards category; 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 ...

  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
    RoD
    RoD is offline
    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, 12:49 PM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01: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, 06:42 PM

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