Thread: Dev-C++ compiler

  1. #1
    Registered User
    Join Date
    Nov 2005
    Location
    Alpine, TX
    Posts
    31

    Dev-C++ compiler

    I recently had an assignment to write a program generating a deck of cards and shuffling them. In c language. I wrote the code on Dev-C++ initially but I could not get the random generator to work . Then I read that c does not have a random number generator only c++. But I copied the code on borland as a c file and everything worked fine. So my question is if its true that c does not have random? If not is there anyway to get around it or maybe another way to generate randoms, or am I stuck doing these assignments on borland?

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    srand() and rand() are both in stdlib.h, found in the C Standard Library.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I read that c does not have a random number generator only c++.
    Nope, C has rand() (which I thought was in <stdio.h>, but as sean_mackrory says, it's actually in <stdlib.h>). So does C++, if you include <cstdlib>.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to Dev C++/<windows.h>...
    By Cilius in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2005, 01:05 AM
  2. Glut and Dev C++, Programs not Quitting?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-29-2004, 08:43 PM
  3. Dev C++ Compiler, Indentation?
    By Zeusbwr in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2004, 06:13 AM
  4. Dev C++ compiler question
    By exluddite in forum C++ Programming
    Replies: 1
    Last Post: 10-16-2004, 09:31 PM
  5. C Compiler
    By SAMSEIED in forum C Programming
    Replies: 5
    Last Post: 06-06-2002, 05:44 PM