functions

Discussion in 'C Programming' started by sonic0568, Dec 8, 2005.

  1. sonic0568

    sonic0568 Guest

    what's the difference between rand() & random() ?

    thanx!
    i am the new comer here,maybe i break some rules that i don't kown
    before;please forgive me...
    sonic0568, Dec 8, 2005
    #1
    1. Advertising

  2. sonic0568

    Ingo Menger Guest

    sonic0568 schrieb:

    > what's the difference between rand() & random() ?


    om
    Ingo Menger, Dec 8, 2005
    #2
    1. Advertising

  3. sonic0568 said:

    > what's the difference between rand() & random() ?


    rand() is a standard C library function, prototyped in the <stdlib.h>
    header. It produces, on successive calls, a series of pseudo-random numbers
    in the range 0 to RAND_MAX. You can set the starting point in that series
    by passing it to srand(), which is also a standard library function.

    random() is whatever you want it to be, subject only to your skill and
    imagination. Implementations are free to provide extra functions as an
    extension if they wish, and they have to call them something, so you might
    want to have a look at your documentation to see whether random() is
    mentioned there. If it is, bear in mind that some other implementation
    might implement that function with different functionality, or not
    implement it at all.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
    Richard Heathfield, Dec 8, 2005
    #3
  4. sonic0568

    Anand Guest

    sonic0568 wrote:
    > what's the difference between rand() & random() ?
    >
    > thanx!
    > i am the new comer here,maybe i break some rules that i don't kown
    > before;please forgive me...
    >
    >

    random() is a non-standard function, So you should see the documentation
    of your compiler.
    <OT>
    My compiler has the following doc.
    | The random() and srandom() functions have (almost) the same
    | calling sequence and initialization properties as rand() and
    | srand() (see rand(3C)). The difference is that rand(3C) pro-
    | duces a much less random sequence-in fact, the low dozen
    | bits generated by rand go through a cyclic pattern. All the
    | bits generated by random() are usable.
    </OT>
    For more details about rand() and generating a random number, see the FAQ.

    --
    (Welcome) http://www.ungerhu.com/jxh/clc.welcome.txt
    (clc FAQ) http://www.eskimo.com/~scs/C-faq/top.html
    Anand, Dec 8, 2005
    #4
  5. sonic0568

    sonic0568 Guest

    and more...richard heathfield...i respect u very much!i'm reading ur book
    these days...it's very helpful to me!

    at the end,if my english has some problems,please let me kown,because my
    mother tongue is not english..

    thank u veeeeerrrry much~~
    sonic0568, Dec 8, 2005
    #5
  6. sonic0568

    sonic0568 Guest

    Anand,thank u very much...
    sonic0568, Dec 8, 2005
    #6
  7. sonic0568

    Flash Gordon Guest

    sonic0568 wrote:
    > and more...richard heathfield...i respect u very much!i'm reading ur book
    > these days...it's very helpful to me!


    Please don't use contractions like "u" for you and "ur" for "your". It
    makes it *much* harder to read your posts.

    > at the end,if my english has some problems,please let me kown,because my
    > mother tongue is not english..


    Poor English due to it not being your native language is not a problem.
    Using contractions like "u" is a problem.

    Also, please provide context when replying to a post. See
    http://cfaj.freeshell.org/google/
    --
    Flash Gordon
    Living in interesting times.
    Although my email address says spam, it is real and I read it.
    Flash Gordon, Dec 8, 2005
    #7
  8. sonic0568

    Jordan Abel Guest

    On 2005-12-08, Flash Gordon <> wrote:
    > Poor English due to it not being your native language is not a problem.
    > Using contractions like "u" is a problem.


    At least, until it becomes standard english it is. Expect this in a
    couple centuries at most, less if you stop fighting it [but it is
    inevitable]
    Jordan Abel, Dec 8, 2005
    #8
  9. sonic0568

    Flash Gordon Guest

    Jordan Abel wrote:
    > On 2005-12-08, Flash Gordon <> wrote:
    >> Poor English due to it not being your native language is not a problem.
    >> Using contractions like "u" is a problem.

    >
    > At least, until it becomes standard english it is. Expect this in a
    > couple centuries at most, less if you stop fighting it [but it is
    > inevitable]


    1) It is not inevitable that it will become standard English.
    2) I was stating the plain and simple truth when I said it is a problem.
    It takes me noticeably more effort and time to read a post using
    those contractions, and others have said the same in the past so it
    is not just me.
    --
    Flash Gordon,
    Dyslexic Software Developer,
    At least the compiler ensures I spell variable names consistently wrong.
    Flash Gordon, Dec 8, 2005
    #9
  10. In article <>,
    Jordan Abel <> wrote:

    >> Poor English due to it not being your native language is not a problem.
    >> Using contractions like "u" is a problem.


    >At least, until it becomes standard english it is. Expect this in a
    >couple centuries at most, less if you stop fighting it [but it is
    >inevitable]


    Do you really think that most people will still be typing text in 200
    years time? I think it's quite likely that most people will not need
    to be able to read or write long before that.

    -- Richard
    Richard Tobin, Dec 8, 2005
    #10
  11. sonic0568

    sonic0568 Guest

    i'll remember what you said;thank you ^ ^

    by the way,the reason that i write that way because i'm a prince fan...he is
    a ture genius...
    sonic0568, Dec 9, 2005
    #11
  12. "sonic0568" <> writes:
    > i'll remember what you said;thank you ^ ^


    One of the things he said was:

    ] Also, please provide context when replying to a post. See
    ] http://cfaj.freeshell.org/google/

    Please read that web page and follow its advice.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Dec 9, 2005
    #12
  13. sonic0568

    Ian Malone Guest

    Richard Tobin wrote:
    > In article <>,
    > Jordan Abel <> wrote:
    >
    >
    >>>Poor English due to it not being your native language is not a problem.
    >>>Using contractions like "u" is a problem.

    >
    >
    >>At least, until it becomes standard english it is. Expect this in a
    >>couple centuries at most, less if you stop fighting it [but it is
    >>inevitable]

    >
    >
    > Do you really think that most people will still be typing text in 200
    > years time? I think it's quite likely that most people will not need
    > to be able to read or write long before that.
    >


    Or think. Actually, that one seems to have happened already.

    --
    imalone
    Ian Malone, Dec 9, 2005
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    11
    Views:
    808
    tshad
    May 27, 2005
  2. Timothy Wong
    Replies:
    3
    Views:
    401
    Timothy Wong
    May 20, 2004
  3. ILLOGIC
    Replies:
    1
    Views:
    349
    Rob Williscroft
    Jun 1, 2004
  4. Xiangliang Meng
    Replies:
    1
    Views:
    1,577
    Victor Bazarov
    Jun 21, 2004
  5. Steven T. Hatton

    Passing member functions to C functions?

    Steven T. Hatton, Oct 4, 2004, in forum: C++
    Replies:
    7
    Views:
    1,304
    David Hilsee
    Oct 7, 2004
Loading...

Share This Page