[RESOLVED] randomize ( )
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: [RESOLVED] randomize ( )

  1. #1
    Join Date
    Jun 1999
    Posts
    488

    [RESOLVED] randomize ( )

    Hi,
    Is there any randomize ( ) function in Visual C++ 6.0? What is its prototype? Plz guide me.

    Zulfi.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: randomize ( )

    Wow! being here since 1999 and cannot use MSDN yet?
    http://msdn.microsoft.com/en-us/libr...(v=vs.60).aspx
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 1999
    Posts
    488

    Re: randomize ( )

    Hi,
    Thanks for your response. I usually check google because it provides example code also. I found following link from MSDN but it does not even tell me its prototype.
    http://msdn.microsoft.com/en-us/library/dd354946.aspx

    The link you have provided tells me about random function. I am looking for randomize().
    I have tried stdlib.h and ctime.h but its still saying undeclared identifier. Plz guide me.

    I have following header files included in my code:
    #include "stdafx.h"
    #include "LaserGraph.h"

    #include "LaserGraphDoc.h"
    #include "LaserGraphView.h"
    #include <stdlib.h>
    #include <time.h>
    #include <iostream.h>
    #include <math.h>
    //#include "time.h"




    Last 4 are added just for randomize().
    Zulfi.
    Last edited by Zulfi Khan2; February 12th, 2014 at 11:11 PM.

  4. #4
    Join Date
    May 2004
    Location
    45,000FT Above Nevada
    Posts
    1,538

    Re: randomize ( )

    Quote Originally Posted by Zulfi Khan2 View Post
    Hi,
    Thanks for your response. I usually check google because it provides example code also. I found following link from MSDN but it does not even tell me its prototype.
    http://msdn.microsoft.com/en-us/library/dd354946.aspx

    The link you have provided tells me about random function. I am looking for randomize().
    I have tried stdlib.h and ctime.h but its still saying undeclared identifier. Plz guide me.

    I have following header files included in my code:



    Last 4 are added just for randomize().
    Zulfi.


    You asked for a randomize function for VC++ 6.0...the link Victor gave you is for that exact function, it is called srand(), and NOT randomize(), there is no such function for VC++ 6.0...his link also gave you the prototype and example code.
    Jim
    ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII

    "The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.

    "Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.

  5. #5
    Join Date
    Jun 1999
    Posts
    488

    Re: randomize ( )

    Hi,
    Thanks for your information.

    Zulfi.

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,882

    Re: randomize ( )

    Note: rand() is pretty much unusable for any but the most simplistic usage cases.

    it's period is too short
    the generated bits per random number are small
    it's cryptographically unsafe
    it's too predictable (you can derive the seed from a single output)
    it has poor dimensional distribution (it's "unstable", causes streaky artefacts)

    The fact it's uniform over 32k, with 32k period and 32k values means it's output isn't even technically "random" because it's impossible to ever get the same 15bit value in succession.



    You're much better off using the random features from the C++ <random> header.
    hint: the mersenne twisters are very good random number generators.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center