By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

Help with C++ <ctime>

P: n/a
I have been searching the internet trying to find the definition for the
function time() in the standard library header <ctime>. Can someone help me
with this? Thanks in advance.
Jul 10 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
B Williams wrote:
I have been searching the internet trying to find the definition for the
function time() in the standard library header <ctime>. Can someone help me
with this? Thanks in advance.

std::clock_t std::time(std::clock_t * tloc) ;

Returns the number of seconds since the Epoch (midnight, Jan 1, 1970).
If tloc is not NULL, it also writes the same value to the location
provided by the parameter.

--
Alan Johnson
Jul 10 '06 #2

P: n/a

"Alan Johnson" <al****@no.spam.stanford.eduwrote in message
news:e8**********@news.Stanford.EDU...
>B Williams wrote:
>I have been searching the internet trying to find the definition for the
function time() in the standard library header <ctime>. Can someone help
me with this? Thanks in advance.

std::clock_t std::time(std::clock_t * tloc) ;

Returns the number of seconds since the Epoch (midnight, Jan 1, 1970). If
tloc is not NULL, it also writes the same value to the location provided
by the parameter.

--
Alan Johnson
Thanks Alan,
I really appreciate it.
Jul 10 '06 #3

P: n/a
B Williams wrote:
I have been searching the internet trying to find the definition for
the function time() in the standard library header <ctime>. Can
someone help me with this? Thanks in advance.

What do you mean by "definition"?


Brian
Jul 10 '06 #4

P: n/a
On Sun, 09 Jul 2006 18:59:09 -0700, Alan Johnson
<al****@no.spam.stanford.eduwrote in comp.lang.c++:
B Williams wrote:
I have been searching the internet trying to find the definition for the
function time() in the standard library header <ctime>. Can someone help me
with this? Thanks in advance.

std::clock_t std::time(std::clock_t * tloc) ;

Returns the number of seconds since the Epoch (midnight, Jan 1, 1970).
If tloc is not NULL, it also writes the same value to the location
provided by the parameter.
time() returns type time_t.

clock() returns type clock_t.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 10 '06 #5

P: n/a
Jack Klein wrote:
On Sun, 09 Jul 2006 18:59:09 -0700, Alan Johnson
<al****@no.spam.stanford.eduwrote in comp.lang.c++:
>B Williams wrote:
>>I have been searching the internet trying to find the definition for the
function time() in the standard library header <ctime>. Can someone help me
with this? Thanks in advance.

std::clock_t std::time(std::clock_t * tloc) ;

Returns the number of seconds since the Epoch (midnight, Jan 1, 1970).
If tloc is not NULL, it also writes the same value to the location
provided by the parameter.

time() returns type time_t.

clock() returns type clock_t.
Correct. Apologies for the misinformation.

--
Alan Johnson
Jul 10 '06 #6

P: n/a
Alan Johnson wrote:
B Williams wrote:
I have been searching the internet trying to find the definition
for the function time() in the standard library header <ctime>.
Can someone help me with this? Thanks in advance.

std::clock_t std::time(std::clock_t * tloc) ;

Returns the number of seconds since the Epoch (midnight, Jan 1,
1970). If tloc is not NULL, it also writes the same value to the
location provided by the parameter.
As Jack mentioned, this is the wrong declaration. You are also
incorrect in the semantics. There's no requirement that time() return
seconds, certainly not seconds since the epoch. That happens to be
common, but portable should not rely on that or need that.

Brian
Jul 10 '06 #7

P: n/a
You can locate the ctime header file using "locate" or "find" commands
on UNIX

Thanks and regards
SJ

Default User wrote:
B Williams wrote:
I have been searching the internet trying to find the definition for
the function time() in the standard library header <ctime>. Can
someone help me with this? Thanks in advance.


What do you mean by "definition"?


Brian
Jul 10 '06 #8

P: n/a
Default User wrote:
>
As Jack mentioned, this is the wrong declaration. You are also
incorrect in the semantics. There's no requirement that time() return
seconds, certainly not seconds since the epoch. That happens to be
common, but portable should not rely on that or need that.
Correct, time_t's encoding is not specified. All you can do is
pass it to otherf unctions. If you want to know elapsed time
from some point, use difftime().
Jul 10 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.