473,802 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4213
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.eduwr ote in message
news:e8******** **@news.Stanfor d.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.eduwr ote 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.l earn.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.eduwr ote 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
7787
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
6097
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 slightly to adjust path names and also take into account I am working with a case-sensitive OS. My program is below. The sticky point is that adding (#include "util.h") seems to negate the (#include <string>) statement somehow. How can I get...
11
5394
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
5422
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
3519
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 std::istringstream but fails to do so, could anybody see what is wrong with the code? (Output follows the code.) I fear that I have not completely grasped how the time_getXXX methods should be used in the operator<< ? With best regards,
9
3689
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 into a struct timeval object. I get the ByteBuffer as an array of const unsigned char, 'buffer'. Here's an example: 00 00 01 0A 29 1D 07 E4 This value maps somehow to Thu Mar 23 16:57:49 2006 and some
3
5266
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 members st_atime, st_mtime, and st_ctime. I don't want any lib fun that returns the corresponding time formatted string coz what I want to know is the interpretation of date-time in those members so that I could extract them and use it for some...
5
3109
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 ChipRecord // Chip Times record { time_t hiStartTime; // Start Time // much more... } timeWork; // entrant info records typedef map<int, ChipRecordBCI;
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10304
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.