RE: [BULK] get minutes of system time as int in c++

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 6 Jun 2008 14:46:34 -0700


That is the system clock all I did was subtract the system clock for when
the program began to the system clock after the loop.  The t1 is the number
of seconds from that date in 1970 so with that you should be able to use the
ctime on the page I sent you to get a printable time.  I really think you
need to read the page I sent you .
-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex Hall
Sent: Friday, June 06, 2008 2:36 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: RE: [BULK] get minutes of system time as int in c++

Got it.  Is there a way to apply this to tracking the system clock instead
of the elapsed time of a program?

Have a great day,
Alex

> ----- Original Message -----
>From: "Ken Perry" <whistler@xxxxxxxxxxxxx
>To: <programmingblind@xxxxxxxxxxxxx
>Date sent: Fri, 6 Jun 2008 14:13:13 -0700
>Subject: RE: [BULK]  get minutes of system time as int in c++


>If you look in time.h you will find that time_t when using dev
c++ is just a
>long int.  And what it is, is the amount of seconds since 1970
some time.
>If you read this page you will learn more.

>http://rabbit.eng.miami.edu/info/functions/time.html

>Why I use null is because that gives you the current time.  I
used the
>modulus because that gives you the remainder in a division in
this case it
>would be 5 seconds.  If you had 70 seconds it would return a
remainder of 10
>instead of 5.

>Ken


>-----Original Message-----
>From: programmingblind-bounce@xxxxxxxxxxxxx
>[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex
Hall
>Sent: Friday, June 06, 2008 1:44 PM
>To: programmingblind@xxxxxxxxxxxxx
>Subject: RE: [BULK] get minutes of system time as int in c++

>Thanks.  A couple questions:
>1.  Exactly what is the time_t object and what can you do with
it?
>2.  Why, to get seconds, do you mod by 60 yet minutes you divide
by 60?
>3.  Why do you pass null to the time function, and what does that
time
>function return?

>Have a great day,
>Alex

>> ----- Original Message -----
>>From: "Ken Perry" <whistler@xxxxxxxxxxxxx
>>To: <programmingblind@xxxxxxxxxxxxx
>>Date sent: Fri, 6 Jun 2008 13:25:37 -0700
>>Subject: RE: [BULK]  get minutes of system time as int in c++



>>Ok while I was waiting on your response I wrote this to check the
>minutes
>>and seconds elapsed while running some commands.  Note I did not
>use any
>>special libraries like a Date class that they have in most
>compilers.  Here
>>is the most basic with out using assembler snicker.  It works for
>both gcc
>>and visual studio's c++  Just delete the defined lines depending
>on what
>>your using.


>>#ifdef VC++_COMPILER
>>#include <windows.h
>>#endif
>>#include <time.h
>>#include <iostream

>>using namespace std;

>>int main(int argc, char* argv[])
>>{
>>time_t t1 = time(NULL);

>>//do some tasks here
>>for (long  i=0;i<65;i++)
>>#ifdef GCC
>>//_sleep(1000);
>>#endif
>>#ifdef VC++_COMPILER
>>Sleep(1000);
>>#endif

>>time_t t2 = time(NULL);
>>int seconds=(t2-t1)%60;
>>int minutes=(t2-t1)/60;

>>cout <<"elapsed time = "<<minutes<< " minutes "<< seconds<< "
>seconds
>>"<<endl;

>>return (0);

>>}



>>-----Original Message-----
>>From: programmingblind-bounce@xxxxxxxxxxxxx
>>[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Ken
>Perry
>>Sent: Friday, June 06, 2008 12:58 PM
>>To: programmingblind@xxxxxxxxxxxxx
>>Subject: RE: [BULK] get minutes of system time as int in c++



>>Oh sorry the original mail did not come to me it got junked I got
>the
>>response and that was the one I was replying to.

>>Now I can tell you how to get system time all the way to the
>assembler level
>>but it helps in knowing what c++ environment your working in
>because it
>>makes a difference for example they have data and time classes in
>Microsoft
>>that is some times easier to use then to actually write the code
>yourself.
>>So tell me what compiler your using and for what operating system
>and I will
>>give you an example.

>>Ken

>>-----Original Message-----
>>From: programmingblind-bounce@xxxxxxxxxxxxx
>>[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex
>Hall
>>Sent: Friday, June 06, 2008 12:34 PM
>>To: programmingblind@xxxxxxxxxxxxx
>>Subject: RE: [BULK] get minutes of system time as int in c++

>>The example did not have stdlib, and stdio was just the word, no
>h.  Thanks.
>>The question still  stands, though: how can  I get the minutes of
>the system
>>time? Apparently there is a time_t object, but I could not find
>much on
>>that.

>>Have a great day,
>>Alex

>>> ----- Original Message -----
>>>From: "Ken Perry" <whistler@xxxxxxxxxxxxx
>>>To: <programmingblind@xxxxxxxxxxxxx
>>>Date sent: Fri, 6 Jun 2008 12:09:03 -0700
>>>Subject: RE: [BULK]  get minutes of system time as int in c++



>>>You should be able to compile a printf into your c++ program as
>>long as you
>>>include the header for printf which is stdio and stdlib with the
>>h
>>>extention.

>>>Ken

>>>-----Original Message-----
>>>From: programmingblind-bounce@xxxxxxxxxxxxx
>>>[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex
>>Hall
>>>Sent: Friday, June 06, 2008 11:04 AM
>>>To: programmingblind@xxxxxxxxxxxxx
>>>Subject: RE: [BULK] get minutes of system time as int in c++

>>>Yes, just the 34 of 16:34.  The examples used printf() which is,
>>I believe,
>>>a c function and stopped my program from compiling in cpp.

>>>Have a great day,
>>>Alex

>>>> ----- Original Message -----
>>>>From: "Sean Farrow" <sean.farrow@xxxxxxxxxxxxxxxx
>>>>To: <programmingblind@xxxxxxxxxxxxx
>>>>Date sent: Fri, 6 Jun 2008 18:27:38 +0100
>>>>Subject: RE: [BULK]  get minutes of system time as int in c++

>>>>Hi Alex:
>>>>Plese could you clarify what you want: if the time is 16:34, do
>>>you just
>>>>want the 34?
>>>>What examples did you fine?
>>>>Sean.

>>>>-----Original Message-----
>>>>From: programmingblind-bounce@xxxxxxxxxxxxx
>>>>[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex
>>>Hall
>>>>Sent: 06 June 2008 17:50
>>>>To: programmingblind@xxxxxxxxxxxxx
>>>>Subject: [BULK] get minutes of system time as int in c++
>>>>Importance: Low

>>>>how could I go about getting the minutes, as an integer, of the
>>>system
>>>>time using cpp? I tried to find it, but got what seemed to be
>>>examples
>>>>in c not cpp.  Thanks.

>>>>Have a great day,
>>>>Alex
>>>>__________
>>>>View the list's information and change your settings at 
>>>>//www.freelists.org/list/programmingblind




>>>>__________ Information from ESET NOD32 Antivirus, version of
>>>virus
>>>>signature database 3164 (20080606) __________

>>>>The message was checked by ESET NOD32 Antivirus.

>>>>http://www.eset.com



>>>>__________ Information from ESET NOD32 Antivirus, version of
>>>virus
>>>>signature database 3164 (20080606) __________

>>>>The message was checked by ESET NOD32 Antivirus.

>>>>http://www.eset.com

>>>>__________
>>>>View the list's information and change your settings at 
>>>>//www.freelists.org/list/programmingblind


>>>__________
>>>View the list's information and change your settings at 
>>>//www.freelists.org/list/programmingblind

>>>__________
>>>View the list's information and change your settings at 
>>>//www.freelists.org/list/programmingblind


>>__________
>>View the list's information and change your settings at 
>>//www.freelists.org/list/programmingblind

>>__________
>>View the list's information and change your settings at 
>>//www.freelists.org/list/programmingblind

>>__________
>>View the list's information and change your settings at 
>>//www.freelists.org/list/programmingblind


>__________
>View the list's information and change your settings at 
>//www.freelists.org/list/programmingblind

>__________
>View the list's information and change your settings at 
>//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: