cplusplus.com
C++ : Forum : UNIX/Linux Programming : something abt time()
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs


post something abt time()

CD4 (28)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include  <time.h>
#include  <stdio.h>
#include  <unistd.h>
#include  <stdlib.h>
int main()
{
    int i;
    time_t the_time;
    for(i = 1; i <= 10; i++) {
         the_time = time((time_t *)0);
         printf(“The time is %ld\n”, the_time);
         sleep(2);
    }
    exit(0);
}

in this example i dint get line 9 time((time_t *)0);
can please some1 help.Code is from the book Beginning linux programming 4th ed.

regards
Bazzy (6258)
From http://www.cplusplus.com/reference/clibrary/ctime/time/ :
The function returns this value, and if the argument is not a null pointer, the value is also set to the object pointed by timer.


(time_t *)0 casts 0 ( NULL ) to a pointer to time_t
CD4 (28)
so bazzy... cant time(NULL) be used aas in example?? what is the significance of the lines coded above (type casting)??

regards
Bazzy (6258)
There isn't any difference so you can put that.
CD4 (28)
thanks bazzy... :)
Topic archived. No new replies allowed.