473,408 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Help with C++ <ctime>

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
8 4182
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

"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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ernst Murnleitner | last post by:
Hello Readers, I am looking for a replacement of <ctime>. for the functions gmtime mktime One reason is, that these time functions use statically allocated memory but
5
by: Danny Anderson | last post by:
Hola! I am working on a program where I am including a library that came with my numerical methods textbook. The "util.h" simply includes a large number of files. I had to change the util.h...
11
by: Charles L | last post by:
I have read that the inclusion of <fstream.h> makes the inclusion of <iostream.h> unnecessary. Is this correct? Charles L
13
by: Matthias Kaeppler | last post by:
Hi, why can I use assert from <cassert> without resolving the std:: namespace? E.g.: #include <cassert> int main() { assert(true); // shouldn't this be: std::assert(true) ?
7
by: Peter Jansson | last post by:
Dear group, I have been struggling to get a simple program for inserting and extracting std::tm objects to/from streams to work. The code below tries to read a std::tm object from a...
9
by: Simple Simon | last post by:
Java longs are 8 bytes. I have a Java long that is coming in from the network, and that represents milliseconds since Epoch (Jan 1 1970 00:00:00). I'm having trouble understanding how to get it...
3
by: Magesh | last post by:
How date-time attributes of a file are represented in the structure "struct stat"? Coz as I noted they found to be unsigned integers and I donno how they are interpreted as date & time in the...
5
by: Mike Copeland | last post by:
I'm having difficulty updating map objects. In the code I've excerpted below, I store map objects without difficulty, but my attempts to modify elements of the stored data don't work. struct...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.