time(0)

This is a discussion on time(0) within the C++ Programming forums, part of the General Programming Boards category; what is the (0) in there for? I've only used time() for seeding the random number generator, and i was ...

  1. #1
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787

    time(0)

    what is the (0) in there for? I've only used time() for seeding the random number generator, and i was just wondering what exactly the 0 is for

    i read this definition, but I don't understand it... which argument? is 0 the argument? if so then how is time stored in 0?
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  2. #2
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    I've never seen `time(0)', I only see `time(NULL)'.
    see more or `$ man 2 time'.
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    The argument to time can be either a pointer to time_t, or a null pointer. Most of the time people will use it with the null pointer and use the return value to assign to a time_t variable. In C++ the use of the macro NULL is not recommended, so the integer literal 0 is used because in pointer context it is treated as a null pointer. To summarize: time ( 0 ) and time ( NULL ) are equivalent. But time ( 0 ) is recommended over time ( NULL ) in C++.
    My best code is written with the delete key.

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    oh, i see now... thanks
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "Multiple Filter Randoms"
    By gnimblegnome in forum C++ Programming
    Replies: 3
    Last Post: 10-28-2007, 01:24 PM
  2. an altenative PRNG seed (other than time(0))
    By major_small in forum C++ Programming
    Replies: 15
    Last Post: 08-05-2005, 09:05 AM

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