Menu

Two different questions for DevCPP

2003-02-10
2012-09-26
  • Nobody/Anonymous

    1) How do i make random numbers based on time?
    2) What are the default graphics libraries, and what include files do i need to access them?

    Any examples you can pose with true code (not just explanations) would be much appreciated.

    Thanks
    -em

     
    • Nobody/Anonymous

      Note first, Dev is just a front end for gcc, so questions about the compiler are best phrased that way.

      (1) Look into rand and srand.  If you want to get any fancier, I use GSL, the Gnu Scientific  Library.
      There have been a number of discussions on the board about this, search on srand and you should find something.

      (2) There are really no "default" libraries.  There are libraries and routines you can link.  I am not however the expert in this area.  (Given enough time and beer I can probably think of an area that I am expert in).  I'm sure the heavyweights will weigh in in a bit on this...

      Wayne

       
    • Anonymous

      Anonymous - 2003-02-10

      1) That may not be very random since time itself is not random! The world is full of poor pseudo random number algorithms, but if you insist you could try setting the random number seed using the current clock() value, and then simply using rand() repeatedly.

      srand( clock() ) ;

      then subsequently,

      rnum = rand() ;

      2) Win32 API! You could download clgdi DevPack if you want simple console mode graphics.

       
    • Nobody/Anonymous

      Try srand(time(NULL)); for initializing the random number generator with a proper seed.

      upcase

       
    • Anonymous

      Anonymous - 2003-02-10

      time() returns a time_t structure, srand() requires an integer.

      clock() returns a type clock_t, which is an integer. It is typedef'ed to allow for different representations on different platforms.

      Strictly speaking I should have written:

      srand( (int)clock() ) ;

       
    • Nobody/Anonymous

      Is is really impossible to use AnimateWindow with MingW 2.0 (w32api 2.2) ?

      Or should I be deffining something I am not?

      Anyone using it?

      Thanks

       
    • Nobody/Anonymous

      What does that have to do with the thread topic?

      Wayne

       
    • Nobody/Anonymous

      About graphics:
      I don't know what is level of your knowlege but downloading and reading big document "Charls Petzold: Programming Windows" is the best for start.

      Hiroaki

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.